unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Announcement: goof-loop 0.1
@ 2021-05-11 12:26 Linus Björnstam
  2021-05-11 14:15 ` Dr. Arne Babenhauserheide
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Björnstam @ 2021-05-11 12:26 UTC (permalink / raw)
  To: guile-user

Hello Friends!

I am rather pleased to announce the first beta release of goof-loop, an extensible, powerful and fast looping facility for (guile) scheme. It is based on (chibi loop), but adds quite a bit of nice things - most notably subloops and a higher order loop protocol based on srfi-158-styled generators. 

The repo can be found here: https://git.sr.ht/~bjoli/goof-loop
Hosted documentation: https://bjoli.srht.site/doc.html

If you are familiar with racket's for loops, you will find these pretty similar, more verbose, and more powerful. Some examples to show highlights compared to racket's loops and foof-loop:

Subloops and accumulators in all loop stages:
(loop ((:for a (in-list '(1 2 3)))
       (:acc aa (summing a))
       :subloop
       (:for b (up-from a (to (+ a 2))))
       (:acc ab (listing b)))
  => (values aa ab))
;; => 6  (1 2 2 3 3 4)

Loop clauses that refer to eachother, here producing a list of fibonacci numbers:
(loop/list ((count (up-from 0 100))
            (a (in 1 b)) 
            (b (in 1 (+ a b))))
  a)

Named updates (shamelessly stolen from Taylor Campbells foof-loop documentation):
(define (partition list predicate)
  (loop continue ((:for element (in-list list))
                  (:acc satisfied (folding '()))
                  (:acc unsatisfied (folding '())))
     => (values (reverse satisfied) (reverse unsatisfied))
     (if (predicate element)
         (continue (=> satisfied (cons element satisfied)))
         (continue (=> unsatisfied (cons element unsatisfied))))))

Pattern matching, here extracting all keys in an alist
(loop/list (((key . val) (in-list '((a . 0) (b . 1) (c .2)))))
  key)

Higher order loop protocol (for the :for clause scheme-value)
(loop/list ((key (in-list '(true false sant falskt wahr falsch vrai faux)))
            (scheme-value (in-cycle (in-list '(#t #f)))))
  (cons key scheme-value))

The loop expansion is usually as fast as a named let.

You can find a lot more tofu in the readme and documentation.

best regards
  Linus Björnstam



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Announcement: goof-loop 0.1
  2021-05-11 12:26 Announcement: goof-loop 0.1 Linus Björnstam
@ 2021-05-11 14:15 ` Dr. Arne Babenhauserheide
  0 siblings, 0 replies; 2+ messages in thread
From: Dr. Arne Babenhauserheide @ 2021-05-11 14:15 UTC (permalink / raw)
  To: Linus Björnstam; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]


Linus Björnstam <linus.internet@fastmail.se> writes:

> I am rather pleased to announce the first beta release of goof-loop, an extensible, powerful and fast looping facility for (guile) scheme. It is based on (chibi loop), but adds quite a bit of nice things - most notably subloops and a higher order loop protocol based on srfi-158-styled generators. 
>
> The repo can be found here: https://git.sr.ht/~bjoli/goof-loop
> Hosted documentation: https://bjoli.srht.site/doc.html
> Pattern matching, here extracting all keys in an alist
> (loop/list (((key . val) (in-list '((a . 0) (b . 1) (c .2)))))
>   key)
>
> Higher order loop protocol (for the :for clause scheme-value)
> (loop/list ((key (in-list '(true false sant falskt wahr falsch vrai faux)))
>             (scheme-value (in-cycle (in-list '(#t #f)))))
>   (cons key scheme-value))
>
> The loop expansion is usually as fast as a named let.

Very cool!

Congrats for the release — and thank you very much for sharing!

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 1125 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-11 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 12:26 Announcement: goof-loop 0.1 Linus Björnstam
2021-05-11 14:15 ` Dr. Arne Babenhauserheide

unofficial mirror of guile-user@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-user/0 guile-user/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-user guile-user/ https://yhetil.org/guile-user \
		guile-user@gnu.org
	public-inbox-index guile-user

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.user
	nntp://news.gmane.io/gmane.lisp.guile.user


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git