If you have a chain of single-argument functions and you want to do something 
side-effectful in the middle of the chain with just the input at that point in 
the chain, you can make a function that converts a void-returning function into 
a function that returns its argument:

(define ((side-effect proc) v)
  (proc v)
  v)

(~> 10
       (* 2)
       (side-effect displayln) ;; prints 20, then passes 20 down the chain
       (+ 5))
;; returns 25

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