Skip to content

Instantly share code, notes, and snippets.

@koba-yu
Last active March 16, 2018 13:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koba-yu/eee26c197685f39632d83d9b8c1db642 to your computer and use it in GitHub Desktop.
Save koba-yu/eee26c197685f39632d83d9b8c1db642 to your computer and use it in GitHub Desktop.
Redでパイプライン演算子的なものを作ってみる
Red []
; パイプ演算子の実体となる関数
pipe: function [x 'y] [value: get y value x]
; 「|>」にpipe関数を演算子としてセット
|>: make op! :pipe
; 使い方はこんな感じになる。残念ながら呼び出される側の関数には「'」を付けないと呼べない・・・
[1 2 3] |> 'rejoin
; returns "123"
"ABC" |> 'lowercase
; returns "abc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment