Reputation: 7
i am trying to do factorial calculator function in Lisp/drRacket but i got problems and cant figure out.
#lang typed/racket
(: n Number)
(define (faktoriyel n)
(cond
((< n 0) (error "eksi sayıların faktoriyeli olmaz"))
((and (>= n 0) (<= n 1)) 1)
(else (* n (faktoriyel (- n 1))))))
Upvotes: 0
Views: 108
Reputation: 780949
You should be declaring the type of the function, not the variable n
:
(: faktoriyel (-> Number Number))
(-> Number Number)
means a function that takes a Number
as a parameter and returns a Number
.
See Function Types in the documentation.
Upvotes: 1