Вопрос

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top