Racket's also flexible enough that you can say "to hell with void, I want
function chaining" if you decide it's more appropriate:
(require fancy-app) ;; now (+ _ 1) means (lambda (v) (+ v 1))
(require point-free) ;; now (~> x f g h) means (h (g (f x)))
;; makes voidful procedures return their argument
(define ((action! proc) v)
(proc v)
v)
;; like ~>, but turns all procedures into actions first
(define (act~> v . procs)
(apply ~> v (map action! procs)))
;; voila!
(act~> (make-vector 5)
(vector-fill! _ 'blank)
(vector-set! _ 2 'grapefruit)
(vector-set! _ 0 'watermelon)
(vector-map! symbol->string _)
(vector-sort! _ string<?)
(vector-map! string-titlecase _))
;; output is '#("Blank" "Blank" "Blank" "Grapefruit" "Watermelon")
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.