This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: StackOverflowError in a specialized map


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]