On Sunday, January 31, 2016 at 1:05:17 PM UTC-5, Alexis King wrote:
> > On Jan 29, 2016, at 21:55, Brian Adkins wrote:
> > 
> > Was any consensus reached on this? I've been working through some exercises 
> > in Racket that a friend is implementing in Elixir, and I just came across a 
> > "method chaining" situation. I ended up simply writing a wrapper function, 
> > but using a version of ~> would've been nice.
> 
> Yes, actually, there was. The “threading” package was the result, and
> you can find the documentation here[1]. I believe rackjure’s threading
> implementation now also uses this package, so at least some level of
> standardization has been reached.

Awesome! I just tried it out, and it works great:

(define (score word)
  (apply + (~> word
               string-trim
               string-downcase
               string->list
               (map (curry hash-ref points) _))))

(define (word-count str)
  (~> str
      string-downcase
      (string-split #px"[^a-z]+")
      (foldl (λ (word hsh) (hash-update hsh word add1 0))
             (make-immutable-hash)
             _)))

> If you want Clojure-style threading macros, the threading package is
> probably your best bet. Of course, that might not actually be what you
> want: consider also looking at the different ~> from the point-free
> package, which is actually a higher-order function. When paired with a
> shorthand function package (which didn’t ever get standardized), it can
> be a little more powerful (and just as concise) than a dumb macro.

I'll check this out later.

-- 
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