public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: Damien MATTEI <Damien.Mattei@unice.fr>,
	kawa@sourceware.org, Sudarshan S Chawathe <chaw@eip10.org>
Subject: Re: StackOverflowError in a specialized map
Date: Tue, 21 Mar 2017 15:47:00 -0000	[thread overview]
Message-ID: <be6988f5-e7a3-058e-3674-836e6986f0a4@bothner.com> (raw)
In-Reply-To: <201703211500.57497.Damien.Mattei@unice.fr>

On 03/21/2017 07:00 AM, Damien MATTEI wrote:
> perheaps some funfamental routines as map* should be written with set-cdr! and loops and never touch them again.... and build functional programming on top of those low level routines...

Yes, I think that makes sense.

Specifically, I think we should import at least 'filter' from SRFI-1
into the default Kawa environment, and optimize it like we already do
for 'map' (which compiles into a loop).

Some of the other SRFI-1 function might also be worth adding.

The invoke branch has "scan patterns" which act like the ellipsis in syntax-rules
patterns:
   (PAT ...)
matches a list (or actually any sequence) assuming each item matches PAT.

The following squares each element of a list:

#|kawa:7|# (define (sq-list [x ...])
#|.....8|#   [(* x x) ...])
#|kawa:9|# (sq-list [5 7 2 3])
#(25 49 4 9)

Scan patterns don't support filtering, but I'm thinking an else-less 'if' might
make sense:

#|kawa:10|# (define (sq-list-pos [x ...])
#|.....11|#   [(if (> x 0) (* x x)) ...]) ;; doesn't work!

However this has not been implemented.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

  reply	other threads:[~2017-03-21 15:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15 15:08 Damien MATTEI
2017-03-15 16:23 ` Per Bothner
2017-03-16 10:54   ` Damien MATTEI
2017-03-17 11:38     ` Damien MATTEI
2017-03-17 14:07       ` Sudarshan S Chawathe
2017-03-21 14:01         ` Damien MATTEI
2017-03-21 15:47           ` Per Bothner [this message]
2017-03-25 22:56           ` Sudarshan S Chawathe
2017-03-26  9:49             ` Damien Mattei
2017-03-26  9:55               ` Damien Mattei
2017-03-26 10:56                 ` Damien Mattei
2017-03-28  8:42             ` Damien MATTEI
2017-03-28 14:21               ` Damien MATTEI
2017-03-17 10:37   ` Damien MATTEI
2017-03-17 16:00     ` Per Bothner

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

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

  git send-email \
    --in-reply-to=be6988f5-e7a3-058e-3674-836e6986f0a4@bothner.com \
    --to=per@bothner.com \
    --cc=Damien.Mattei@unice.fr \
    --cc=chaw@eip10.org \
    --cc=kawa@sourceware.org \
    /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).