# Resolve Scheme operational syntax’s [duplicate]

The first programming language that I learned was Scheme. One of my first projects was to create an interpreter in Scheme that can take any basic arithmetic operation and translate it to Scheme prefix notation. Back then, I couldn´t sleep for some days.

The basic arithmetic operation in Scheme is like this:

(operator N1 N2 N3 N3 ... Nn)

Where operator is any of the basic operators (+ , - . * ,/), and N is any number or operation of the same form.

Given any basic arithmetic operation, translate it to Scheme prefix notation.

• Basic arithmetic operation means any operation that uses “+ , - . * , /” and “( )”
• The input is a string, and may or may not contain spaces between numbers and operators.
• The output should be in the form described before, and should give the correct result when operated in any online interpreter.

Test Cases

• Given 1 + 2 the output should be (+ 1 2)
• Given 1 + 2 + 3 the output should be (+ 1 2 3)
• Given 1 + (2 * 3) the output should be (+ 1 (* 2 3))
• Given 2 * 3 + 4 the output should be (+ (* 2 3) 4)

This is , so shortest answer in bytes wins.

• with input: 1 + 2 + 3, is outputting: (+ 1 (+ 2 3)) acceptable? – Felipe Nardi Batista Jul 25 '17 at 14:43
• Translate to prefix notation might be more general, it's not Scheme-specific – Mr. Xcoder Jul 25 '17 at 14:46
• @FelipeNardiBatista, no. Only if the original operation has parenthesis. – Kenny Barrera Jul 25 '17 at 14:46
• @Mr.Xcoder i dont think that general prefix notation works with (+ 1 2 3) – Felipe Nardi Batista Jul 25 '17 at 14:47