[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Problems with srfi-4-comprehensions
From: |
Alex Shinn |
Subject: |
Re: [Chicken-users] Problems with srfi-4-comprehensions |
Date: |
Thu, 22 Mar 2007 17:45:19 +0900 |
On 3/16/07, Alex Shinn <address@hidden> wrote:
On 3/16/07, Ivan Raikov <address@hidden> wrote:
>
> Could someone who actually understands Scheme macros and
> comprehensions take a look at this? Thanks a bunch,
I won't touch SRFI-42, but if you'd use it I'll provide a SRFI-4
extension to loopy-loop :)
I almost forgot about this. I just updated loopy-loop with support for
SRFI-4 by default (it's only one extra line of compile-time code per
vector type, not really bloat).
#;1> (use syntax-case loopy-loop srfi-4)
#;2> (loop ((x <- in-u8vector '#u8(1 2 3))) (print x))
1
2
3
I also added the in-cartesian-product iterator which takes a list of
lists and iterates over the full cartesian product (right joins, may add
left joins later) of those lists, with a fast algorithm using only O(n)
space where n is the number of elements of the initial lists.
#;3> (loop ((x <- in-cartesian-product '((a b) (c d e)))) (print x))
(a c)
(a d)
(a e)
(b c)
(b d)
(b e)
#;4>
For those of you currently using srfi-42 or CL's loop or otherwise
hesistant to try loopy-loop, let me point out some advantages of
loopy-loop:
1) It's simpler and easier to use. It really is. If the documentation
doesn't reflect this well, tell me so I can improve it :)
2) It's more general. It gracefully handles changes as your loop grows
in complexity and accumulates ad-hoc special cases.
3) It's fast. It produces very simple, tight code with no mutations.
All the alternatives use mutation.
4) It's compile-time only. There are no run-time dependencies, making
it suitable even if you don't want to use any module system.
5) It's actively developed and tested to work with either syntax-case or
syntactic-closures, whichever you prefer. The latter is smaller and
faster.
6) It preserves line number debugging information when used with
syntactic-closures.
7) It allows implicit destructuring-bind on all loop variables.
8) It has lots of nifty iterators (e.g. hash-tables, permutations and
combinations) not found by default in the alternatives.
--
Alex
Re: [Chicken-users] Problems with srfi-4-comprehensions, felix winkelmann, 2007/03/16