guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Megacut - a clojure-like lambda shorthand


From: Linus Björnstam
Subject: Megacut - a clojure-like lambda shorthand
Date: Tue, 26 Mar 2019 16:22:52 -0400
User-agent: Cyrus-JMAP/3.1.5-976-g376b1f3-fmstable-20190314v3

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]