Type Checker: Declaration for `n' provided, but `n' has no definition in: n

i am trying to do factorial calculator function in Lisp/drRacket but i got problems and cant figure out.

enter image description here

#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

Answers (1)

Barmar
Barmar

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

Related Questions