Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ansi_common_lispが読めるようになりたい2 #TechLunch
Search
Livesense Inc.
PRO
April 23, 2014
Technology
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ansi_common_lispが読めるようになりたい2 #TechLunch
2011/10/26(水) @ Livesense TechLunch
発表者:春日 太志
Livesense Inc.
PRO
April 23, 2014
More Decks by Livesense Inc.
See All by Livesense Inc.
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
130
Rubyはただの⾔語に⾮ず
livesense
PRO
0
580
28新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
130
27新卒_総合職採用_会社説明資料
livesense
PRO
0
7.5k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
13k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
600
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
1
1.8k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
730
26新卒_総合職採用_会社説明資料
livesense
PRO
0
13k
Other Decks in Technology
See All in Technology
Metadata - Section 1: HTML Basics
mohab1
0
120
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
420
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
190
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
170
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
170
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
go-sqletch
moznion
0
140
Getting Started with Google Antigravity
glaforge
0
300
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
USB PDを使ってスマホを労わりたい
raspython3
0
180
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
サブエージェントと Claude Mods で作る独自 Advisor ツールの話
kenichiodo
2
160
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Cult of Friendly URLs
andyhume
79
7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Marketing to machines
jonoalderson
1
5.9k
Embracing the Ebb and Flow
colly
88
5.2k
Site-Speed That Sticks
csswizardry
13
1.6k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
360
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
Transcript
@bar_̲row 2011年年10⽉月19⽇日 Livesense Inc. 1
⽬目次 Livesense Inc. 2 1. 関数 2. ⼊入出⼒力力 3. 変数
4. 代⼊入 5. 反復復 6. リスト
1-‐‑‒1. 関数(関数の定義) Livesense Inc. 3 > (defun my-third (x)) (car
(cdr (cdr x))) MY-THIRD > (my-third ’(a b c d)) C Ø 関数の定義は defun オペレータを使う Ø defun の引数は通常「関数名」「引数リスト」「関数本体」 Ø リストの指定要素を取得するアクセス関数オペレータ nth, first – tenth, cxr
1-‐‑‒2. 関数(関数オブジェクト) Livesense Inc. 4 > (function +) #<compiled-function +>
> #’+ #<compiled-function +> Ø function オペレータで関数オブジェクトを得る Ø quote と同様に #ʼ’ のエイリアスがある
1-‐‑‒3. 関数(call, apply, map) Livesense Inc. 5 > (apply #’+
1 2 ’(3 4 5)) 15 > (funcall #’* 1 2 3 5) 30 > (mapcar #’(lambda (x) (* x 2)) ’(1 2 3)) (2 4 6) Ø apply はパラメータの最後がリストである必要がある Ø funcall はパラメータがリストでなくてよい Ø リストの各要素に関数を適⽤用するオペレータは何個かある
1-‐‑‒4. 関数(無名関数) Livesense Inc. 6 > (lambda (x y) (+
x y) (LAMBDA-CLOSURE () () () (X y) (+ X Y)) > ((lambda (x y) (+ x y)) 1 2) 3 > (funcall #’(lambda (x y) (+ x y)) 1 2) 3 Ø lambda はオペレータではなくシンボル、古い Lisp の名残 Ø 即時実⾏行行できるし、#ʼ’ で関数オブジェクトを得られる
2. ⼊入出⼒力力 Livesense Inc. 7 > (format t“~A plus ~A
equals ~A.~%”2 3 (+ 2 3)) 2 plus 3 equals 5. NIL > (read) > a A Ø format は「出⼒力力場所」「書式」「挿⼊入値」を受け取る Ø read は構⽂文解析して得られた Lisp オブジェクトを返す
3. 変数 Livesense Inc. 8 > (let ((x 1) (y
2)) (+ x y) 3 > (defparameter *age* 27) *AGE* > (defconstant limit 35) LIMIT Ø 変数定義は局所変数は let、⼤大域変数は defparameter を使う Ø ⼤大域変数名の前後のアスタリスクは慣習 Ø 局所変数で初期化した変数は let の本体内でのみ使⽤用可能 Ø ⼤大域定数で使われたシンボルを変数名として使うとエラー
4. 代⼊入 Livesense Inc. 9 > (setf *age* 28) 28
> (let ((n 10)) (setf n 2) n) 2 > (setf a 1 b 2) 2 > (setf (car ’(1 2 3)) 4) (4 2 3) Ø 変数への代⼊入には setf Ø ⼀一般化参照 Ø setf の第⼀一引数が局所変数 でない場合は⼤大域変数と みなされる
5-‐‑‒1. 反復復 Livesense Inc. 10 > (do ((i 0 (+
i 1))) ((> i 5) ’done) (format t“~A~%”i)) 0 1 2 3 4 5 DONE Ø (変数 初期値 更更新式) Ø (終了了判定式 終了了後実⾏行行式) Ø (本体式)
5-‐‑‒2. 反復復(dolist) Livesense Inc. 11 > (let ((len 0)) (dolist
(elem ’(a b c d e)) (setf len (+ len 1))) len) 5 Ø リストの反復復処理理を⾏行行うのであれば dolist が便便利利
6-‐‑‒1. リスト(proper list) Livesense Inc. 12 Ø コンス(コンスセル)は概念念的には⼀一対のポインタ Ø 第⼀一ポインタは
car 部を、第⼆二ポインタは cdr 部を指す Ø コンスだけからなるリストは真リストと呼ばれる nil a (A) (list ’a)
6-‐‑‒2. リスト(proper list) Livesense Inc. 13 nil a b c
(A B C) (list ’a ’b ’c)
6-‐‑‒3. リスト(proper list) Livesense Inc. 14 nil a b d
(A (B C) D) c (list ’a ’(b c) ’d) nil
6-‐‑‒4. リスト(dotted list) Livesense Inc. 15 Ø 真リストでないコンスはドットリストと呼ばれる Ø ’(a
b c) は ’(a . (b . (c . nil))) と書いても同じ nil a (A) (cons ’a nil) a (A . B) (cons ’a ’b) b
6-‐‑‒5. リスト(assoc list) Livesense Inc. 16 Ø ドットリストで連想リストが⽣生成できる Ø assoc
オペレータで指定キーのドットリストを取得 Ø しかしパフォーマンスは低い > (setf hoge ’((+ .“add”) (- .“substract”)) ((+ .“add”) (- .“substract”)) > (cdr (assoc ’+ hoge)) “add” > (assoc ’* hoge) NIL
Livesense Inc. 17