Eduardo Cavazos wrote:
PS: Going back to your comment about confusing syntax, I wonder how
you'd feel about the J programming language! ;-) Or K, Q, etc...
J has alot of shorthand notation. :-)
> (import (j misc))
With it's arithmetic operators, for example '+', you can add two numbers:
> (+ 2 3)
5
Add a number and a list:
> (+ 2 '(3 4 5))
(5 6 7)
Add two lists:
> (+ '(1 2 3) '(4 5 6))
(5 7 9)
Add a number and a procedure:
> (+ 2 sqrt)
#<procedure>
> ((+ 2 sqrt) 16)
6
Etc.
(j misc) is included below.
By the way, J comes from Ken Iverson who also invented APL. From the
"criticisms of APL" article on Wikipedia:
In a 2007 book, A Demon Of Our Own Design, financial risk management
expert Richard Bookstaber argues that APL became a cult in certain
brokerage firms and investment banks in the 1980s, and that its
inability to elegantly deal with loops contributed to some of the
financial crises of the 1980s and 1990s.
;-)
"Economy of expression" doesn't necessarily lead to a good
"Expression of Economy".
Ed
(library (j misc)
(export + - * /)
(import (rename (rnrs)
(+ rnrs:+)
(- rnrs:-)
(* rnrs:*)
(/ rnrs:/)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-syntax define-binary-arithmetic-procedure
(syntax-rules ()
( (make-binary-arithmetic-procedure name operator)
(define (name a b)
(cond ( (and (procedure? a)
(procedure? b))
(lambda (x)
(name (a x)
(b x))) )
( (procedure? a)
(lambda (x)
(name (a x) b)) )
( (procedure? b)
(lambda (x)
(name a (b x))) )
( (and (list? a)
(list? b))
(map name a b) )
( (list? a)
(map (lambda (a-elt)
(name a-elt b))
a) )
( (list? b)
(map (lambda (b-elt)
(name a b-elt))
b) )
( else (operator a b) ))) )))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-binary-arithmetic-procedure + rnrs:+)
(define-binary-arithmetic-procedure - rnrs:-)
(define-binary-arithmetic-procedure * rnrs:*)
(define-binary-arithmetic-procedure / rnrs:/)
)