From: "Linus Björnstam" <linus.internet@fastmail.se>
To: guile-user@gnu.org
Subject: Re: Happy birthday, Guile!
Date: Sun, 16 Feb 2020 17:20:48 +0100 [thread overview]
Message-ID: <4ec25ad7-282d-4948-979e-93315faf4237@www.fastmail.com> (raw)
In-Reply-To: <874kvq1syo.fsf@gnu.org>
Hooray! I have a bunch of small utils that I use to make repl life easier. One thing I did to scratch an itch is a clojuresque lambda shorthand (cut on steroids) for guile. It transverses whatever expressions you put into it and rewrites it into a lambda where all identifiers of the form %n where n is an integer gets transformed into a lambda argument.
https://hg.sr.ht/~bjoli/megacut/browse
(megacut (let ((a "Hello ")) (string-append a %1)))
=> (lambda (%1) (let ((a "Hello")) (string-append a %1)))
Using read-hash-extend one can write #%:
#%(apply + (/ 10 %1) %&)
=> (lambda (%1 . %&) (apply + (/ 10 %1) %&))
It supports arbitrary many arguments, and also allows for "ignoring" arguments:
#%(display %3)
=> (lambda (%1 %2 %3) (display %3))
A regular % is also a shorthand for %1:
#%(+ % %) => (lambda (%1) (+ %1 %1))
I use it daily. 20 minutes of scripting that the last year or so probably saves me at least 25 seconds of typing :)
It has rudimentary unhygienic support for nesting, which may or may not be a terrible idea.
I have another useful little function, port->list which takes a port and a read function and returns a list of whatever the reader function returns until the port EOFs. less powerful than port-fold, but less fuss to use when you just want a list. I leave that as an exercise for the reader, though.
--
Linus Björnstam
On Sun, 16 Feb 2020, at 15:56, Ludovic Courtès wrote:
> Hello Guilers!
>
> Today, it’s been 9 years since Guile 2.0 came out!
>
> https://lists.gnu.org/archive/html/guile-devel/2011-02/msg00173.html
>
> It’s impressive how much has been accomplished since 2.0, and how what
> seemed like a pipe dream back then came into reality with 3.0. I think
> Guile 2.0 started a renaissance of Guile, and it’s in bloom now. :-)
>
> We used to have a “Guile potluck” for the anniversary, where people
> would bring their own hacks and virtually join for a party. We missed
> it this year, but if there’s a nice hack that you’d like to share, now
> is a good time!
>
> Happy hacking with Guile!
>
> Ludo’.
>
> Attachments:
> * signature.asc
next prev parent reply other threads:[~2020-02-16 16:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-16 14:56 Happy birthday, Guile! Ludovic Courtès
2020-02-16 16:20 ` Linus Björnstam [this message]
2020-02-16 18:36 ` Arun Isaac
2020-02-16 21:08 ` sirgazil
2020-02-16 19:14 ` Roel Janssen
2020-02-16 19:30 ` Ricardo Wurmus
2020-02-17 9:16 ` Ludovic Courtès
2020-02-18 13:38 ` Christopher Lam
2020-02-18 13:44 ` Lenses in Guile? Zelphir Kaltstahl
2020-02-18 14:04 ` Alex Sassmannshausen
2020-02-19 14:27 ` Zelphir Kaltstahl
2020-02-23 17:00 ` Ludovic Courtès
2020-02-16 21:13 ` Happy birthday, Guile! Mike Gran
2020-02-16 21:34 ` sirgazil
2020-02-16 21:54 ` Ricardo Wurmus
2020-02-16 22:14 ` Jeremy Korwin-Zmijowski
2020-02-16 23:51 ` potluck; " Arne Babenhauserheide
2020-02-17 0:10 ` Happy birthday, Guile! - grid printing Zelphir Kaltstahl
2020-02-17 8:01 ` Linus Björnstam
2020-02-17 14:58 ` Zelphir Kaltstahl
2020-02-17 16:21 ` Linus Björnstam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ec25ad7-282d-4948-979e-93315faf4237@www.fastmail.com \
--to=linus.internet@fastmail.se \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).