|
From: | Hans Åberg |
Subject: | Re: List functions |
Date: | Fri, 3 Dec 2010 10:20:25 +0100 |
On 2 Dec 2010, at 17:06, Hans Aberg wrote:
Another problem: passing a list of length two to a function that takes two non-arguments. For example,(define h (lambda (x y) (display x) (display y))) and passing (list 1 2) to it.It is in the same context as before: I want to build functions like in Haskellf((1, 2), 3) where f = \((x, y), z) -> (x, y, z) --> (1,2,3)
I found that this is possible by:(define f (lambda (a z) (primitive-eval (cons (lambda (x y) (+ x y z)) a))))
Then (f (list 1 2) 3) --> 6The primitive "list" is important here, as shown in the examples by Keith. So it seems one should type data-lists by adding this symbol. But it is not available in the C-interface as symbol, so I added it in my interface, and in fact a variation called "tuple", which is the same as "list", only that (tuple x) --> x.
[Prev in Thread] | Current Thread | [Next in Thread] |