I cannot print output.What I need to do?Could you fix me please? This is for api (ns…
- User
I cannot print output.What I need to do?Could you fix me please? This is for api (ns lab4-clj.api)
(defn constant "Constructor for constant" [value] {:pre [(or (= value 0) (= value 1))]} (list ::const value))
(defn constant? "Check if expr is constant" [expr] (= (first expr) ::const))
(defn constant-value
"Get constant value" [expr] (second expr))(defn variable "Constructor for variable" [name] {:pre [(keyword? name)]} (list ::var name))
(defn variable? "Check if expr is variable" [expr] (= (first expr) ::var))
(defn variable-name "Get variable name" [var] (name (second var)))
(defn logic-not "Constructor for negation" [expr] (list ::not expr))
(defn logic-not? "Check if expression is negation" [expr] (= (first expr) ::not))
(defn logic-or "Constructor for disjunction" [expr & rest] (if (empty? rest) expr (cons ::or (cons expr rest))))
(defn logic-or? "Check if expression is disjunction" [expr] (= (first expr) ::or))
(defn logic-and "Constructor for conjunction" [expr & rest] (if (empty? rest) expr (cons ::and (cons expr rest))))
(defn logic-and? "Check if expression is conjunction" [expr] (= (first expr) ::and))
(defn logic-impl "Constructor for implication" [expr1 expr2] (list ::impl expr1 expr2))
(defn logic-impl? "Check if expression is implication" [expr] (= (first expr) ::impl))
(defn logic-xor "Constructor for XOR (exclusive OR)" [expr1 expr2] (list ::xor expr1 expr2))
(defn logic-xor? "Check if expression is XOR" [expr] (= (first expr) ::xor))
(defn logic-pierce-arrow "Constructor for Pierce arrow" [expr1 expr2] (list ::pierce expr1 expr2))
(defn logic-pierce-arrow? "Check if expression is Pierce arrow" [expr] (= (first expr) ::pierce))
(defn get-type [expr] (keyword (first expr)))
(defn same-type? "Check that expr1 and expr2 are of the same type" [expr1 expr2] (= (first expr1) (first expr2)))
(defn args "Get arguments of operation" [expr] (rest expr))
(defn first-arg "Get arguments of operation" [expr] (first (rest expr)))
(defn second-arg "Get arguments of operation" [expr] (second (rest expr)))
(defn combine-same-args "Combine arguments of the same type in one operation" [expr] (if (or (constant? expr) (variable? expr)) (list expr) (->> (args expr) (mapcat #(if (same-type? expr %) (combine-same-args %) (list %))))))
(defn expr-to-str "Converting expression to string" [expr] (cond (constant? expr) (constant-value expr) (variable? expr) (variable-name expr) (logic-not? expr) (str "(" (str "¬" (expr-to-str (first (args expr)))) ")") (logic-or? expr) (str "(" (reduce #(str %1 " | " %2) (expr-to-str (first (args expr))) (map expr-to-str (rest (args expr)))) ")") (logic-and? expr) (str "(" (reduce #(str %1 " & " %2) (expr-to-str (first (args expr))) (map expr-to-str (rest (args expr)))) ")") (logic-impl? expr) (str "(" (reduce #(str %1 " -> " %2) (expr-to-str (first (args expr))) (map expr-to-str (rest (args expr)))) ")") (logic-pierce-arrow? expr) (str "(" (reduce #(str %1 " ↓ " %2) (expr-to-str (first (args expr))) (map expr-to-str (rest (args expr)))) ")") (logic-xor? expr) (str "(" (reduce #(str %1 " ⊕ " %2) (expr-to-str (first (args expr))) (map expr-to-str (rest (args expr)))) ")"))) This is for core (ns lab4-clj.core (:require [lab4-clj.api :refer :all]) (:require [lab4-clj.dnf :refer :all]))
- Assistant
- User
No I cannot output your result.This is an error.Could you tell me please what i need to do? Syntax error compiling at (main.clj:220:35). Unable to resolve symbol: dnf in this context
Full report at: /tmp/clojure-2283444503074412093.edn
[Execution complete with exit code 1]
- Assistant
- User
I don't understand what is it? src/ └── lab4_clj/ ├── api.clj ├── core.clj └── dnf.clj
- Assistant