racket - (scheme) can define a function but can't call it -
i trying write function calls map function n times on list. pretty simple problem:
(define (mapntimes f x l) (if (= x 0) l (mapntimes (f (- x 1) map (f l))))) dr racket gives me following error when try , call function. using statement this:
(mapntimes ((lambda (x) (* 2 x))) 2 '(1 2 3)) it gives me error
expected: number? given: '(3 5 1) argument position: 2nd other arguments...: 2 i know syntax can't life of me figure out is. appreciate help.
perhaps new scheme , not familiar syntax invoking scheme functions.
given function f, invoke using:
(f arg1 arg2) not
f (arg1 arg2) this works me.
(define (mapntimes f x l) (if (= x 0) l (mapntimes f (- x 1) (map f l))))
Comments
Post a Comment