UFC Insider
UFC Insider

Reputation: 838

How to call a function that's inside a list?

I have a list of functions flist that receive 1 argument. I am trying to call the first function and pass 1 as an argument to it:

((car flist) 1)

And then I get:

 expected: pair? given: #<procedure:hash2>

I also tried:

(((car flist) 1))

But then I get another error:

 expected a procedure that can be applied to arguments

What am I doing wrong?

Upvotes: 0

Views: 102

Answers (1)

&#211;scar L&#243;pez
&#211;scar L&#243;pez

Reputation: 236004

I think your function list wasn't properly built. For example, this works:

(define flist (list sin cos tan))
((car flist) 1)
=> 0.8414709848078965

Upvotes: 1

Related Questions