[plt-scheme] Lambda in a list... am I doing something wrong?

From: krhari at ccs.neu.edu (krhari at ccs.neu.edu)
Date: Mon Oct 19 22:50:16 EDT 2009

Hi,

If I am not wrong, cdr returns a list. So when you have ((cdr (car commands))), it will give you ((list your-lambda)). So if you want just your function, try ((car (cdr (car commands)))). You might get your desired result ("test"). 

Hari

----- Original Message -----
From: "Jon Rafkind" <rafkind at cs.utah.edu>
To: "Timothy McDowell" <tmcdowell at gmail.com>
Cc: plt-scheme at list.cs.brown.edu
Sent: Monday, October 19, 2009 7:43:30 PM GMT -05:00 US/Canada Eastern
Subject: Re: [plt-scheme] Lambda in a list... am I doing something wrong?

Timothy McDowell wrote:
> I'm trying to write a little interactive fiction, and I have a setup like
> this:
> (define commands
> '(
> ("look" (lambda () (display "test")))))
>
>   

Try (define commands (list (list "look" (lambda () (display "test")))))

> The response I get from trying ((cdr (car commands))):
> procedure application: expected procedure, given: ((lambda () (display
> "test"))) (no arguments)
>
> Can someone explain to me what I am doing wrong?
>
> --  Thanks,
> --Timothy.
>
>   
> ------------------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   

_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.