Re: λ notation



Here are some of my ideas:

;; this is a simple macro
(mapcar (λ (α) (+ α 10)) '(1 2 3 4))

;; this can be done with a reader macro
(mapcar Λ(+ α 10) '(1 2 3 4)) ;; greek characters are implicit
arguments in alphabetical order

;; this can also be done with a macro
(mapcar (« + 10) '(1 2 3 4)) ;; where '«' is like curry

;; this kind of compose implicitly takes function names as arguments
;; probably needs to be done after read and before compile by
processing the contents recursively
;; CL is not flexible enough to be able to implement easily such
syntax extensions
(find element list :key (a ° b ° c))

;; these are easy
(≠ 1 2)
(≤ 1 3)
(√ 16)
(Σ '(1 2 3 4))
(Π '(1 2 3 4))

;; recursive calls
(defun gcd (a b)
(if (= b 0)
a
(if (< a b)
(↻ b a)
(↻ b (mod a b)))))

and many more...

To type in a greek character one can either type 'lambda' and let
emacs replace it by 'λ' or bind it to a key such as C-l with an
appropriate prefix. It is also possible to type in 'lambda' and let
emacs display it as 'λ' even though the file contains the word
'lambda'. The other special characters could be handled similarily.

And as soon as we forget about storing and editing the code as simple
text files this whole notation issue becomes a matter of taste/
preference per user per session per whatever you want...

levy
.



Relevant Pages

  • Re: =?utf-8?Q?=CE=BB?= notation
    ... ;; this can be done with a reader macro ... To type in a greek character one can either type 'lambda' and let ... emacs display it as 'λ' even though the file contains the word ...
    (comp.lang.lisp)
  • =?ISO-8859-7?Q?Re:_=EB_notation?=
    ... ;; this can be done with a reader macro ... To type in a greek character one can either type 'lambda' and let ... emacs display it as 'λ' even though the file contains the word ...
    (comp.lang.lisp)
  • Re: Macros in the car of an application
    ... > try to write a macro that would allow things like that. ... > a macro I called flambda. ... Note that your macro could assume that all of the lambda variables are ... symbols by duplicating the value bindings into function bindings. ...
    (comp.lang.lisp)
  • Re: Paul Grahams Arc is released today... what is the long term impact?
    ... unfortunate choice for a *very prominent* keyword. ... macro just to change the name of something so ubiquitous smells of a bad ... even "lambda calculus" has the fussy sound of having come from the ... the "telling youself stories" about your code, ...
    (comp.lang.lisp)
  • Re: Forms in functional position: asking the implementors (Re: Is it possible to implement ,@ if it
    ... named F. So you'd need to perform the evaluation in a special way, ... not otherwise taken up by a macro, special operator, or lambda expression. ...
    (comp.lang.lisp)