>
> The other thing I'd like to see would be the option to return nothing.
> Not #<void>, '(), or #f.  Nothing.  It's useful e.g. when you want to
> simultaneously transform and filter a list.
>

Would (values) satisfy your criteria?

#lang racket

(define (my-filter-map proc xs)
  (match xs
    ['() '()]
    [(cons x xs)
     (call-with-values
      (thunk (proc x))
      (case-lambda
        [() (my-filter-map proc xs)]
        [(x) (cons x (my-filter-map proc xs))]))]))

(my-filter-map (λ (x) (if (odd? x) (values) (add1 x))) '(1 2 3 4)) ;=> '(3 5)

One thing I don’t like about it is that zero values (and multiple values in
general) are really unwieldy to work with and doesn’t compose well with the
rest of Racket. You can for example translate v >>= f in Haskell to just (and
v (f v)) in Racket. But trying to do the same thing with zero values is a
headache.

>
> On Wed, Jul 17, 2019 at 11:50 PM Daniel Prager <daniel.a.pra...@gmail.com>
> wrote:
>
>> I'm confused on one point.
>>
>> Why would a new canonical notation be preferable to, say, also fully
>> supporting an alternative general notation (like Shriram's p4p, or a
>> derivative thereof) or even multiple notations in addition to retaining
>> good old s-expressions?
>>
>> The idea would be that you could transform freely and readably between
>> alternative notations, enabling round-tripping without degradation.
>>
>> I imagine that effectively providing tooling, syntax-extension, good
>> error messages, and documentation across multiple notations would be (ahem)
>> challenging, but so long as we're dreaming big ...
>>
>>
>> Dan
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAFKxZVV-njHNCCLDP-RsDq%2BjbXrOGpOnaEp9Ob4ugTbdtmckAw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/racket-users/CAFKxZVV-njHNCCLDP-RsDq%2BjbXrOGpOnaEp9Ob4ugTbdtmckAw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAE8gKodKrWNeL3tJQ5uO4X64jKzBVmYY2P9BgLsd%3Dqh8bhSQyw%40mail.gmail.com
> <https://groups.google.com/d/msgid/racket-users/CAE8gKodKrWNeL3tJQ5uO4X64jKzBVmYY2P9BgLsd%3Dqh8bhSQyw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcueguTp19B7Yqb9nZM%3DJfiofWU4-JBdC-aaoFXq4vthUe3NQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to