unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Hans Åberg" <hans.aberg-1@telia.com>
To: Hans Aberg <haberg-1@telia.com>
Cc: guile-user@gnu.org
Subject: Re: List functions
Date: Fri, 3 Dec 2010 10:20:25 +0100	[thread overview]
Message-ID: <985EC07C-7E3A-41D8-9EC0-AD799319DEA0@telia.com> (raw)
In-Reply-To: <D3044473-1119-415C-B50B-78D03C8D498C@telia.com>

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 Haskell
>  f((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) --> 6

The 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.




      reply	other threads:[~2010-12-03  9:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-01 16:28 List functions Hans Aberg
2010-12-01 17:35 ` Joel James Adamson
2010-12-01 17:48   ` Hans Aberg
2010-12-01 19:20     ` Keith Wright
2010-12-01 19:50       ` Hans Aberg
2010-12-01 20:26         ` Hans Aberg
2010-12-01 21:34         ` Keith Wright
2010-12-01 22:19           ` Hans Aberg
2010-12-01 22:43           ` Hans Aberg
2010-12-03 15:06           ` Hans Aberg
2010-12-01 19:51 ` Andy Wingo
2010-12-01 19:56   ` Hans Aberg
2010-12-02  9:57 ` Marco Maggi
2010-12-02 10:10   ` Marco Maggi
2010-12-02 11:31   ` Hans Aberg
2010-12-02 16:06   ` Hans Aberg
2010-12-03  9:20     ` Hans Åberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=985EC07C-7E3A-41D8-9EC0-AD799319DEA0@telia.com \
    --to=hans.aberg-1@telia.com \
    --cc=guile-user@gnu.org \
    --cc=haberg-1@telia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).