SRFI like cut (SRFI-26) but with ordered arguments Jakub T. Jankiewicz (14 Aug 2021 07:30 UTC)
Re: SRFI like cut (SRFI-26) but with ordered arguments Shiro Kawai (14 Aug 2021 08:57 UTC)
Unicode lambda revisited Lassi Kortela (14 Aug 2021 09:45 UTC)
Re: Unicode lambda revisited Lassi Kortela (14 Aug 2021 09:52 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (15 Aug 2021 06:17 UTC)
Re: Unicode lambda revisited Peter (15 Aug 2021 17:21 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (15 Aug 2021 17:28 UTC)
Re: Unicode lambda revisited Vladimir Nikishkin (16 Aug 2021 07:37 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (16 Aug 2021 10:58 UTC)
Re: Unicode lambda revisited Shiro Kawai (16 Aug 2021 12:09 UTC)
Re: Unicode lambda revisited Jeronimo Pellegrini (16 Aug 2021 12:54 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (16 Aug 2021 13:38 UTC)
Re: Unicode lambda revisited Jeronimo Pellegrini (16 Aug 2021 14:58 UTC)
Re: Unicode lambda revisited Jakub T. Jankiewicz (16 Aug 2021 19:11 UTC)
Re: Unicode lambda revisited John Cowan (16 Aug 2021 15:49 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (16 Aug 2021 19:56 UTC)
Re: Unicode lambda revisited Shiro Kawai (16 Aug 2021 23:26 UTC)
Re: Unicode lambda revisited John Cowan (17 Aug 2021 03:40 UTC)
Re: Unicode lambda revisited Shiro Kawai (17 Aug 2021 04:15 UTC)
Re: Unicode lambda revisited John Cowan (17 Aug 2021 15:04 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (17 Aug 2021 15:34 UTC)
Re: Unicode lambda revisited John Cowan (17 Aug 2021 19:00 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (17 Aug 2021 19:22 UTC)
Re: Unicode lambda revisited Shiro Kawai (17 Aug 2021 20:40 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (17 Aug 2021 20:49 UTC)
Re: Unicode lambda revisited John Cowan (18 Aug 2021 23:13 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (19 Aug 2021 16:03 UTC)
Re: Unicode lambda revisited Daphne Preston-Kendal (19 Aug 2021 16:19 UTC)
Re: Unicode lambda revisited Marc Nieper-Wißkirchen (19 Aug 2021 16:49 UTC)
Re: Unicode lambda revisited Daphne Preston-Kendal (16 Aug 2021 21:03 UTC)
Re: Unicode lambda revisited John Cowan (16 Aug 2021 21:37 UTC)
Re: Unicode lambda revisited Lassi Kortela (17 Aug 2021 05:04 UTC)
Re: Unicode lambda revisited Peter (16 Aug 2021 16:58 UTC)
Re: Unicode lambda revisited Arthur A. Gleckler (16 Aug 2021 17:00 UTC)
Re: Unicode lambda revisited Lassi Kortela (16 Aug 2021 17:36 UTC)
Re: Unicode lambda revisited Arthur A. Gleckler (16 Aug 2021 17:56 UTC)
Re: Unicode lambda revisited Vladimir Nikishkin (17 Aug 2021 04:37 UTC)

SRFI like cut (SRFI-26) but with ordered arguments Jakub T. Jankiewicz 14 Aug 2021 07:30 UTC

Can you use [SRFI-26](https://srfi.schemers.org/srfi-26/srfi-26.html) or
other SRFI to quickly create a function with changed order of arguments?
There should be syntax like:

(define take (cut take <2> <1>))

will swap the arguments in take. With this you can make complex change of the
original function that need different order of arguments. For example to be
able to curry that function.

The take function from SRFI-1 is specified as (take <list> <n>) so you can
use:

(define take2 (cut take <> 2))

But it would be much better to have function that you can call curry on:

(define take2 (curry take 2))

curry can be a function and could be used in places where macro can't.

PS: is there SRFI that define curry for Scheme? Or something that work
similarly?

In my implementation I'm using feature of JavaScript functions that has
length property that return number of parameters the function accepts.
So the function can keep returning lambda expression until all parameters are
passed.

(define (add a b c d)
  (+ a b c d))

(define sum (curry add))
((sum 1 2) 4 5)
;; ==> 12

NOTE that the original curry definition returns single argument functions,
but you still need to get length of the arguments the function accepts.

--
Jakub T. Jankiewicz, Web Developer
https://jcubic.pl/me