Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'matthewp-ternary'

Conflicts:
	include/macros.sibilant
  • Loading branch information...
commit 70c9cb2bc09405482af06d6fedc9f39452f7334d 2 parents 50c9f8f + 28dfedd
@jbr authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 include/macros.sibilant
View
15 include/macros.sibilant
@@ -35,7 +35,7 @@
" " comparator " "
(get args (+ 1 index))))))
")"))
-
+
(defmacro > (&rest args) (macros.infix-comparator ">" (map args translate)))
(defmacro < (&rest args) (macros.infix-comparator "<" (map args translate)))
(defmacro <= (&rest args) (macros.infix-comparator "<=" (map args translate)))
@@ -323,14 +323,14 @@
(setf case-name (if (array? second)
(map second macros.quote)
(macros.quote second))))
-
+
(defvar case-string
(if (array? case-name)
(join "\n" (map case-name (lambda (c)
(concat "case " (translate c) ":"))))
(if (= 'default case-name) "default:"
(concat "case " (translate case-name) ":"))))
-
+
(lines.push (concat case-string
(indent (apply macros.progn (case-def.slice 1))))))
@@ -365,5 +365,10 @@
(defmacro slice (list &optional begin &optional end)
(concat "Array.prototype.slice.call(" (translate list)
- ", " (or (translate begin) 0) (if (defined? end) (concat ", "
- (translate end) ")") ")")))
+ ", " (or (translate begin) 0)
+ (if (defined? end) (concat ", " (translate end) ")") ")")))
+
+(defmacro ternary (cond if-true if-false)
+ (concat "(" (translate cond) ") ? "
+ (translate if-true) " : "
+ (translate if-false)))

0 comments on commit 70c9cb2

Please sign in to comment.
Something went wrong with that request. Please try again.