Extend your language: Difference between revisions

Content added Content deleted
(Added Fennel.)
Line 908: Line 908:
( scratchpad ) 3 [ 0 > ] [ even? ] bi [ 0 ] [ 1 ] [ 2 ] [ 3 ] 2ifte .
( scratchpad ) 3 [ 0 > ] [ even? ] bi [ 0 ] [ 1 ] [ 2 ] [ 3 ] 2ifte .
2</lang>
2</lang>

=={{header|Fennel}}==
<lang fennel>;; Fennel, being a Lisp, provides a way to define macros for new syntax.
;; The "`" and "," characters are used to construct a template for the macro.
(macro if2 [cond1 cond2 both first second none]
`(if ,cond1
(if ,cond2 ,both ,first)
(if ,cond2 ,second ,none)))

(fn test-if2 [x y]
(if2 x y
(print "both")
(print "first")
(print "second")
(print "none")))

(test-if2 true true) ;"both"
(test-if2 true false) ;"first"
(test-if2 false true) ;"second"
(test-if2 false false) ;"none"</lang>


=={{header|Forth}}==
=={{header|Forth}}==