Last active
March 16, 2018 13:19
-
-
Save koba-yu/eee26c197685f39632d83d9b8c1db642 to your computer and use it in GitHub Desktop.
Redでパイプライン演算子的なものを作ってみる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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