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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Livesense Inc.
PRO
April 23, 2014
Technology
78
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
Transcript
17 slides
@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
More Decks by Livesense Inc.
See All by Livesense Inc.
新規商品の開発におけるAIの活用 〜挑戦は人間にしかできない〜
livesense
PRO
0
32
味覇で作るパスタが美味い - 20261001_yabaubuki.dev
livesense
PRO
0
200
Rubyはただの⾔語に⾮ず
livesense
PRO
0
610
28新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
180
27新卒_総合職採用_会社説明資料
livesense
PRO
0
7.8k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
13k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
620
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
1
1.8k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
750
Other Decks in Technology
See All in Technology
ゼロから作るWebアプリの新定番!?Amplify Gen 2 × AWS Blocksで実現する「開発速度とRDBの柔軟性のいいとこ取り」
amixedcolor
1
250
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
高品質と高スピードを支える品質のシフトレフトのアプローチ
goyoki
2
850
田んぼの見回りをIoTで減らしたい!水位監視から電池駆動カメラまでの試行錯誤
itosoft
1
170
E2E Test というハーネス — AI時代の自動テスト民主化
daishukojima
1
470
bpf_arenaとstruct_opsを使うのが難しかった話
masu_mi
0
230
Intro to Kiro (One agent, every surface) | Kiro: Zero to Hero 01
inariku
PRO
2
120
[JAWS Festa 2026]一番いい仕事は、請求書に現れない / jawsfesta2026
sh_fk2
2
520
Claude Securityを使ってみた / claude-security-claude-code-meetup-nagoya
tnir
0
110
属人化したISMS運用をGitHubとAIで仕組み化した1年間の記録
sioncojp
4
2.6k
Datadog の権限統制 〜Org 統合に向けて調べた注意点 / JDDUG-Meetup_24
visional_engineering_and_design
1
120
Kiro Web 入門 (サインインから、頼み方、PR の受け取り、クラウドの決まりまで) | 目指せ Kiro マスター 04
inariku
PRO
2
110
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Test your architecture with Archunit
thirion
2
2.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
It's Worth the Effort
3n
188
29k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
590
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
310
Bash Introduction
62gerente
615
220k
Are puppies a ranking factor?
jonoalderson
2
4.2k
Balancing Empowerment & Direction
lara
6
1.4k