Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> writes:
> Am Mi., 10. Juni 2020 um 00:19 Uhr schrieb Arne Babenhauserheide <
> xxxxxx@web.de>:
>
>>
>> Lassi Kortela <xxxxxx@lassi.io> writes:
>>
>> >>>> (chain (floor/ 5 2)
>> >>>> (- <2> <1>))
>> >>
>> >> It would be possible by replacing `<2>' with `(<> 2)'.
>>
>
>> Could <2> not be a shorthand for (<> 2) — for single-digit numbers?
>> That would give brevity and flexibility.
>>
>
> Sure, you can do
>
> (define-syntax <2> (identifier-syntax (<> 2)))
>
> but you will always have a bounded number of such definitions in a program.
> That said, `<1>', ..., `<10>' are probably more than enough.
I think so, yes.
> But being explicit (by naming the intermediate results) is probably still
> much better.
>
>>
>> >> But at least in this case, `(receive (x y) (floor/ 5 2) (- y x))' is
>> >> much clearer (and no new syntax for Scheme programmers).
>> >
>> > +1. We Schemers are already prone to obfuscating our code with "cadr"
>> > and "cdar" instead of giving clear names to the intermediate things :)
>>
>> How would this look for three steps? Like this?
>>
>> (receive (a b) (receive (x y) (floor/ 5 2)
>> (values (- y x) (+ y x)))
>> (* a b))
>>
>
> You would use `let*-values':
>
> (let*-values (((x y) (floor/ 5 2))
> ((a b) (values (- y x) (+ y x))))
> (* a b))
>
> I think this is pretty concise and clear.
I see it as pretty good. It does not support and-let* syntax, though. Or
does it?
Sidetopic: I just found and=> in Guile:
and=> value proc
(and=> (assoc 'foo '((foo . bar)))
symol->string)
Best wishes,
Arne
--
Unpolitisch sein
heißt politisch sein
ohne es zu merken