unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Megacut - a clojure-like lambda shorthand
@ 2019-03-26 20:22 Linus Björnstam
  2019-03-26 20:32 ` Amirouche Boubekki
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Björnstam @ 2019-03-26 20:22 UTC (permalink / raw)
  To: guile-user

Hello everybody!

I have written a bunch of small libraries to scratch some itches, and I thought now might be a good time to actually release them here. 

Megacut is the first of a few. It is a lambda shorthand, like cut, but with different semantics and more features:

(megacut (apply + (/ %1 %2) %&))

(lambda (%1 %2 . %&) (apply + (/ %1 %2) %&))

Using guile's read-hash-extend #%(+ %1 %2) gets expanded to (megacut (+ %1 %2)).

The workings are simple: positional arguments are %n (where n is a positive integer) and rest arguments are %&. It adds as many positional arguments as n is big so #%(display %2) becomes (lambda (%1 %2) (display %2)). 

The symbol % is a shorthand for %1, so #%(+ % %) is the same as #%(+ %1 %1).

It can be found here: https://bitbucket.org/bjoli/megacut

Play with it if you want. It is licensed under a BSD-styled license. My linux box died recently, so I haven't been able to package it for guix.

Best regards
Linus Björnstam



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

end of thread, other threads:[~2019-03-26 20:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 20:22 Megacut - a clojure-like lambda shorthand Linus Björnstam
2019-03-26 20:32 ` Amirouche Boubekki

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