Skip to content

Instantly share code, notes, and snippets.

@MarkJr94
Created December 29, 2016 23:18
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 MarkJr94/d8c8cbb55e8597b66147a2ca2c012eab to your computer and use it in GitHub Desktop.
Save MarkJr94/d8c8cbb55e8597b66147a2ca2c012eab to your computer and use it in GitHub Desktop.
(ns clojure-noob.core
(:gen-class))
;; This function works as expected
;; (macroexpand '(infix (1 + 1))) => (+ 1 1)
(defmacro infix
[infixed]
(let [[arg1 binop arg2] infixed]
(list binop arg1 arg2)))
;; This one for some reason thinks it needs two arguments, but should be the same
;; (macroexpand '(infix2 (1 + 1) ()))) => (+ 1 1)
;; (macroexpand '(infix2 (1 + 1))) => ArityException
(defmacro infix2
[[arg1 binop arg2] infixed]
(list binop arg1 arg2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment