Fork me on GitHub
Frank Jay01:03:05

(defn eval-not



(and (seq? (second input)) (= 'and (first (second input)))) ;(do x here which -> (or (not x) (not y))
If the user types in: (eval-not '(not (and x y))), is there a way to return (or (not x) (not y)) Without using macros and without changing the style of code I have already written above. I asked this question before, but I was not very specific as to what I was asking. I hope this question is better written.


is there any particular reason the style of the code canโ€™t be changed?


@U7RJTCH6J yes there is: it's a homework assignment ๐Ÿ™‚

bananadance 2
๐Ÿ˜… 1
Frank Jay03:03:36

Well. I created the homework assignment and I did any other functions in the same format. Would appreciate any advice :)


(defn demorgan
    (atom? form)

    (and (= 'not (first form))
         (sequential? (second form))
         (= 'and (first (second form))))
    (let [[_ [_ & terms]] form]
      (list* 'or (map (comp #(list 'not %) demorgan) terms)))



(demorgan '(not (and x y)))
(demorgan '(not (and (not (and x y)) z)))

Luis C. Arbildo16:03:12

Any form to express it more short and intuitive?

Luis C. Arbildo16:03:05

maybe without necessity to use the function int-or-nothing


That if-let global is bad

Luis C. Arbildo17:03:57

Is just an example

Luis C. Arbildo17:03:12

if-let is in a function


probably cond-> by the looks


wait you only have a single condition there

Luis C. Arbildo17:03:09

yes, I just want to corroborate if this difference is greater than 0, and asign this value to a variable


(let [diff (- ...)]
  (when (> diff 0)
    (str diff)))


btw it's generally considered bad-form to use if-let and if without else branches. if you have no else branch use when and when-let

๐Ÿ‘ 2
Luis C. Arbildo17:03:43

Thank you for that!


no worries


@UUGUA0MGQ if you don't mind, please post text instead of images, much easier to read for me anyway. To get syntax coloring you can post a snippet with Ctrl-Shift-Enter and select Clojure for the Type.

Nate Sutton20:03:43

I might make that a ms-until function, so like (ms-until unix-time) where returning nil means it's in the past

๐Ÿ‘ 1