clisp converting between infix, postfix, prefix (i'm trying if statements)
-
06-06-2021 - |
Вопрос
I'm using CLISP and am trying
(if ( = (first '(+ 2 3)) + ) 10 20) //10 and 20 are just placeholders
I am trying to create a program that converts between infix, postfix, and prefix. I believe that my first step should be finding the symbols +, -, *, and / in the string. There will be no parentheses in the input. So, i am trying to search for each symbol systematically. the advantage of my approach is the ability to prioritize * over + etc.
I have a general idea of my approach, but any thoughts would be nice. my first idea is:
(append (rest '(+ 2 3)) (list (first '(+ 2 3))))
and yes, i plan on using recursion.
Решение
some more googling brought me to What's the difference between eq, eql, equal, and equalp in Common Lisp? so i decided to implement "eq" instead of "=" and it worked just as expected.
Не связан с StackOverflow