Created
April 15, 2015 15:31
-
-
Save tangentstorm/62cf02da611cce9e5c84 to your computer and use it in GitHub Desktop.
pattern matching code in j!
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
NB. since the 'case' clauses are evaluated dynamically, | |
NB. you can use them to create something similar to pattern | |
NB. matching in erlang/prolog/haskell: | |
ite =: verb define | |
select. 'f g h' =. y | |
case. 1,g,h do. g | |
case. 0,g,h do. h | |
case. f,1,0 do. f | |
case. do. | |
'otherwise...' | |
end. | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment