Re: List functions

2010-12-03 Thread Hans Ã…berg
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 lik

Re: List functions

2010-12-03 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: One can set the constants to functions that evaluate to themselves. One use would be expressions like (1 + f)(x). The () just shows up in the context above. I didn't really follow that, but in seems that you want to be able to apply a list of funct

Re: List functions

2010-12-02 Thread Hans Aberg
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 Haskell f((1, 2), 3) where f = \((

Re: List functions

2010-12-02 Thread Marco Maggi
"Hans Aberg" wrote: > I am writing on a parser that translates normal function > syntax in to Guile code. I do not know which scenario you are working with, but it is perfectly possible to convert the input syntax: ((sin , cos , tan) 1.2) to the output: ((lambda args (map (lambda (f)

Re: List functions

2010-12-02 Thread Marco Maggi
"Marco Maggi" wrote: >"Hans Aberg" wrote: >> I am writing on a parser that translates normal function >> syntax in to Guile code. > > I do not know which scenario you are working with, but it > is perfectly possible to convert the input syntax: > > ((sin , cos , tan) 1.2) Sorry, I have been too

Re: List functions

2010-12-02 Thread Hans Aberg
On 2 Dec 2010, at 10:57, Marco Maggi wrote: I am writing on a parser that translates normal function syntax in to Guile code. I do not know which scenario you are working with, ... I have a Bison/Flex parser/lexer combination that writes Guile code directly by calling Guile C-functions,

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: I was trying variations like (let () (define (g x)(lambda (f)(f x))) (map (g 2) '(sin cos))) Which gives an error: In expression (f x): Wrong type to apply: sin Somebody should patch that so that it mentions the wrong type. it

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 22:34, Keith Wright wrote: On the other hand |list| is an ordinary variable so, (list sin cos) is evaluated by evaluating the three subexpressions, giving a function that makes lists and two numeric functions of a numeric vaiable, and then applying the first function, i.e. list

Re: List functions

2010-12-01 Thread Keith Wright
> Cc: adams...@email.unc.edu, guile-user@gnu.org > From: Hans Aberg > > I was trying variations like >(let () > (define (g x)(lambda (f)(f x))) > (map (g 2) '(sin cos))) > Which gives an error: >In expression (f x): >Wrong type to apply: sin Somebody should patc

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:50, Hans Aberg wrote: ... in standard syntax would be natural to let (f, g)(x) evaluate to (f(x), g(x)), producing a list of two elements. In Guile, that would be something involving "map". If I try in Haskell, I can let (sin, cos)(2) be the same as map (g 2) [sin, cos] whe

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:51, Andy Wingo wrote: () x into (() x) What is the meaning of this? Did you mean () x into (map (lambda (f) (f x)) '()) ? I am trying to eliminate the "\" of the Haskell binding syntax \ ... - > f, by making the parser grammar rule for ... the same as evaluation

Re: List functions

2010-12-01 Thread Andy Wingo
Hi Hans, On Wed 01 Dec 2010 17:28, Hans Aberg writes: > () x into (() x) What is the meaning of this? Did you mean () x into (map (lambda (f) (f x)) '()) ? Regards, Andy -- http://wingolog.org/

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 20:20, Keith Wright wrote: ... in standard syntax would be natural to let (f, g)(x) evaluate to (f(x), g(x)), producing a list of two elements. In Guile, that would be something involving "map". If I try in Haskell, I can let (sin, cos)(2) be the same as map (g 2) [sin, cos]

Re: List functions

2010-12-01 Thread Keith Wright
> From: Hans Aberg > Cc: guile-user@gnu.org > > On 1 Dec 2010, at 18:35, Joel James Adamson wrote: > > >> I am writing on a parser that translates normal > >> function syntax in to Guile code. > >> > >> It seems natural to translate (f, g) x into ((f g) x), If "(f, g) x" is (in normal syntax)

Re: List functions

2010-12-01 Thread Hans Aberg
On 1 Dec 2010, at 18:35, Joel James Adamson wrote: It seems natural to translate (f, g) x into ((f g) x), and () x into (() x), but I'm not sure if the lists (f g) and () can be made acting as functions this way. (f g) would evaluate as a composition as long as f takes a procedure as an arg

Re: List functions

2010-12-01 Thread Joel James Adamson
Hans Aberg writes: > It seems natural to translate (f, g) x into ((f g) x), and () x into > (() x), but I'm not sure if the lists (f g) and () can be made acting > as functions this way. (f g) would evaluate as a composition as long as f takes a procedure as an argument and returns a function th

List functions

2010-12-01 Thread Hans Aberg
I am writing on a parser that translates normal function syntax in to Guile code. It seems natural to translate (f, g) x into ((f g) x), and () x into (() x), but I'm not sure if the lists (f g) and () can be made acting as functions this way. So what would be natural here? (Constants might