https://zhuanlan.zhihu.com/p/145798175Bing(common lisp by examples)可以看到个很好的介绍,Bing(lisp online)可以在线试。我们直奔higher order functions,file i/o, bitwise operations简直是亵渎,食人间烟火的还叫女神么?
As one of the few homoiconic languages, Lisp is able to treat any/all of it's own source code as lisp data structures, which in turn allows lisp programs to create, alter, and run lisp code "on the fly". A language is homoiconic "if a program written in it can be manipulated as data using the language非人话."
The word Sapien comes from a Latin word meaning 'Wise', it is most commonly recognized when used with the word 'Homo' (a Greek word meaning 'same, or man').
higher order functions - functions that take functions as parameters. apply, eval, eval-when, funcall, map, maplist, mapcar, reduce, lambda, function, closure
(setf x (map 'list 'expt '(4 5 3 2 .25) '(0.5 1 2 3 .5)))
(format t "~A~%" x)
;注释用;开始 format和printf类似,(expt 4 0.5)求4的0.5次方,pow(4, 0.5), setf x是x=
; builds list out of (expt 4 0.5) (expt 5 1) (expt 3 2) ... giving (2.0 5 9 8 0.5)
; (reduce 'function '(list of values))
(setf x (reduce '- '(1 2 3 4)))
(format t "~A~%" x)
; equivalent of (((1-2)-3)-4) giving -8; 没看懂为啥不是(- (- (- 1 2) 3 ) 4)
; if a function, f, has been previously defined, we can assess its body through (function f)
(defun sum (a b) (+ a b))
(format t "function sum is implemented as: ~A~%" (function sum))
; statements can be unnamed functions using lambda
; a statement that evaluates to an unnamed function that computes x^2 + y^2
; (lambda (x y) (+ (* x x) (* y y)))
; closures: functions that build and return customized versions of functions
; the built function has the form (f x) and the purpose of the function is return (x+N)
(defun buildAdder (N) (lambda (x) (+ x N)))
(setf f (buildAdder 3))
(format t "~A~%" (funcall f 1))
lisp - a fault in the way someone speaks which makes them pronounce 's' sounds as 'th'LISP, an acronym for list processing, is a programming language that was designed for easy manipulation of data strings. Developed in 1959 by John McCarthy, it is a commonly used language for artificial intelligence programming.
--
FROM 106.121.71.*