2015年12月13日日曜日 2時21分21秒 UTC+9 Alex Knauth:
> > On Dec 12, 2015, at 9:18 AM, Taro Annual <sagyo12341...@gmail.com> wrote:
> 
> > In racket libraries, rackjure module looks usable.
> > But, rackjure's threading(~>) denys lambda.
> > 
> > ----
> > #lang rackjure
> > 
> >> (#fn(map sqr %) '(1 2))
> > '(1 4)
> >> (~> '(1 2) #fn(map sqr %))
> > [Error] lambda: not an identifier, identifier with default, or keyword in: 
> > (1 2)
> 
> This will work if you use (~> '(1 2) [#fn(map sqr %)]).
> 
> Or, if you use the `~>` from the point-free package instead, (~> '(1 2) 
> #fn(map sqr %)) works fine. In the point-free package, ~> is a function, so 
> it works with values (i.e. functions) instead of not-quite-expressions.
> 
> >> (define (sqrlst lst) (map sqr lst))
> >> (~> '(1 2) sqrlst)
> > '(1 4)
> > ----
> > 
> > In this case, what is the suitable solution?
> > Thank you for reading.
> > 
> > Taro

Thanks, Alex.

I'll use point-free and srfi/26 module.

#lang racket
(require point-free srfi/26)

(define (distance lst)
  (~> lst
      (cut map sqr <>)
      (cut apply + <>)
      sqrt))

> (distance '(3 4))
5

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to