Skip to content

Instantly share code, notes, and snippets.

@tangentstorm
Created April 15, 2015 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangentstorm/62cf02da611cce9e5c84 to your computer and use it in GitHub Desktop.
Save tangentstorm/62cf02da611cce9e5c84 to your computer and use it in GitHub Desktop.
pattern matching code in j!
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