|
|
|
|
|
by rol
3770 days ago
|
|
If you have Quicklisp[1] installed you can install the "infix" package and get infix notation in Common Lisp[2]: $ sbcl
This is SBCL 1.2.4.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
> (ql:quickload 'infix)
; Loading package
(INFIX)
> #i(1 + 1) ; addition
2
> #i(2^^128) ; exponentiation
340282366920938463463374607431768211456
> (defun factorial (x)
#i(if x == 0 then
1
else
x * factorial(x-1))) ; infix function call
FACTORIAL
> (factorial 5)
120
> #i(factorial(5) / factorial(6))
1/6
> '#i((a + b) * (c + d)) ; Put a ' before the #i() to see what code is generated
(* (+ A B)
(+ C D))
--[1] - https://www.quicklisp.org/beta/
[2] - Don't know if there is a similar package for Scheme. |
|
I have to agree with others in the thread that infix in Lisp/Scheme is not the convention, and IMO an awkward fit. Don't recall encountering infix in any published/shared code I've seen, it may exist, but to learn Scheme becoming comfortable with s-expr notation is definitely necessary.
However, there is SRFI 105[0] which describes "curly infix expressions". It's implemented in Guile 2.x, possibly available in a few others but evidently not had a lot of uptake among Schemes.
[0] http://srfi.schemers.org/srfi-105/srfi-105.html
Edit: added URL