; Create an infix function that takes a list like (1 + 3 * 4 - 5) and transforms
; it into the lists that Clojure needs in order to correctly evaluate the
; expression using operator precedence rules.
(defn infix [expr]
(let [splitted (str/split expr #" ")]
splitted))
(print (infix "(1 + 3 * 4 - 5) ") )
P.S. Do not allow print to mislead you! For this kind of troubleshooting, it’s best to work in the REPL and let it do the printing. Look at what detail is omitted by print:
You can call (read-string "(1 + 3 * 4 - 5)") to get '(1 + 3 * 4 - 5) (a list of numbers and symbols) back. You can do any processing with that you like, partition, filter, …
Judging by the comment you have there outlining the exercise, it doesn’t seem like your function should be taking a string at all. The way I read it, you are supposed to accept an expression such as the list '(1 + 3 * 4 - 5) and then inside your function reorder it to become (- (+ 1 (* 3 4) 5) which you can then evaluate. Parsing strings as Clojure code seems like missing the point of the exercise, and if parsing was the objective, regular expressions are definitely not the right tool for the job.
Your exercise says “a list like”, so you should assume that the function should be able to evaluate any kind of basic arithmetic enclosed in a list, not just that specific example.