본문 바로가기

자연수의 합, 자연수의 제곱의 합을 구하는 lisp 식 1. 자연수의 합을 구하는 lisp 식 (defun sum-int (a b) (if (> a b) 0 (+ a (sum-int (+ a 1) b)))) ;; a는 시작하는 자연수 b는 끝 자연수 2. 자연수의 제곱의 합을 구하는 lisp 식 (defun sum-sq (a b) (if (> a b) 0 (+ (* a a) (sum-sq (+ a 1) b)))) ;; a는 시작하는 자연수 b는 끝 자연수 계산 예) 1) 1 + 2 + 3 + ..... + 10 = (sum-int 1 10) = 55 2) 3 + 4 + 5 + ..... + 10 = (sum-int 3 10) = 52 3) 5 + 6 + 7 + ..... + 20 = (sum-int 5 20) = 200 4) 1*1 + 2*2 + 3*3 + .. 더보기
01. Understanding Symbol Manipulation from LISP (3rd edition) by Patrick Henry Winston, Berhold Klaus Paul Horn Symbol manipulation is like working with words and sentences. a code for wordlike Objects and sentencelike Objects ---> sequence of Bits In LISP, wordlike objects are call atoms sentencelide objects are called lists Atoms and lists are collectively called symbolic expressions, or expressions, A symbol-manipulation program .. 더보기
lisp 관련 유용한 사이트 Common Lisp: A Gentle Introduction to Symbolic Computation Entire book -- PDF (1 MB file) A Gentle Introduction Successful Lisp (See chap. 3 for a "nutshell" summary) - http://www.psg.com/~dlamkins/sl/chapter24.html - http://www.psg.com/~dlamkins/sl/chapter12.html - http://www.psg.com/~dlamkins/sl/chapter21.html Online Tutorials for programming Common Lisp or with Common Lisp ... Practical Commo.. 더보기
sucessful lisp LIST 와 ATOM : 유연성의 설명, 리스트에서 데이타와 프로그램이 혼재할 수 있다는 점 a form : 평가될 수 있는 형태, 값이 평가되는 것이면 리스트와 아톰 모두 form이 될 수 있다 a symbol: 값을 가진 상수인 아톰 그 자체 : 패키지 접두어(prefix)인 키워드 심볼을 나타냄 a form이 리스트 이면 첫번째 요소는 symbol(함수명)이거나 lambda expression이라 불리는 special form이 된다. prefix notation 방식을 따른다: 함수명을 문두에 쓰는 방식 (function argument1 argument2 argument3 ...) numbers are self-evaluated. predicate란: 참 또는 거짓을 반환할 수 있는 명제(진술).. 더보기
Lisp의 조건식 (IF ) (WHEN ) (UNLESS ) (COND ( ) ( ) ( ) ( )) 더보기