[racket] Type of argument in a function

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sun Jul 20 08:24:07 EDT 2014

#lang typed/racket

(: plus : Number Number -> Number)
(define (plus x y)
  (+ x y))

(plus 1 2)
(plus "x" 3)


2014-07-20 13:53 GMT+02:00 Jens Axel Søgaard <jensaxel at soegaard.net>:
> #lang racket
>
> (define (plus x y)
>   (unless (and (number? x) (number? y))
>     (error 'plus (~a "expected two numbers, got: " x " " y)))
>   (+ x y))
>
> (plus 1 2)
> (plus "x" 3)
>
> 2014-07-20 13:04 GMT+02:00 קוראל אלימלך <coral2301 at gmail.com>:
>> How can i define that a function will get an integer argument?
>>
>> is its possible?
>>
>> for example:
>> (define (func (x::Number))) /// its not working that way
>>
>> and if ill call the function with string there will be an error..
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>
>
>
> --
> --
> Jens Axel Søgaard



-- 
--
Jens Axel Søgaard


Posted on the users mailing list.