Skip to content

Commit

Permalink
Templates examples
Browse files Browse the repository at this point in the history
Match macro with examples of templates.
Use #(lf,test_pets.trac)' to see
  • Loading branch information
qubeat committed May 25, 2018
1 parent e2154f7 commit 6bc21ff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
17 changes: 17 additions & 0 deletions examples/def_pets.trac
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
( Example of templates
)
#(lf,match.trac)
#(ds,dog,Dog[x])
#(ss,dog,x)
#(ds,cat,Cat[x])
#(ss,cat,x)
#(ds,cat_says,x says "meow")
#(ss,cat_says,x)
#(ds,dog_says,x says "woof")
#(ss,dog_says,x,else)
#(ds,pets,(Pets[x,y]))
#(ss,pets,x,y)
#(ds,pets_say,X and Y say "wow")
#(ss,pets_say,X,Y)
#(ds,says,(#(match,cat,(x),cat_says,#(match,dog,(x),dog_says,#(match,pets,(x),pets_say,what?)))))
#(ss,says,x)
7 changes: 7 additions & 0 deletions examples/match.trac
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
( match macro: #(match,template,string,result,else)
template and result are functions defined via ds/ss
)
#(ds,chk_arg,(#(eq,(arg),(),else,#(fun,arg))))
#(ss,chk_arg,fun,arg,else)
#(ds,match,(#(chk_arg,func,##(te,name,(expr)),else)))
#(ss,match,name,expr,func,else)
19 changes: 19 additions & 0 deletions examples/test_pets.trac
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
( Testing of templates
)
#(lf,def_pets.trac)
(
Test cat
)
#(says,Cat[Alice])
(
Test dog
)
#(says,Dog[Bob])
(
Test both
)
#(says,(Pets[Alice,Bob]))
(
Test unknown
)
#(says,Cow)

0 comments on commit 6bc21ff

Please sign in to comment.