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
racket言語解説
Search
yuyays
July 23, 2025
130
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
racket言語解説
yuyays
July 23, 2025
More Decks by yuyays
See All by yuyays
akarenga_june.pdf
yuyays
0
99
LLMでBang( バング)検索
yuyays
0
130
快適なWeb体験を
yuyays
0
17
Vibe codingと私はバイブするん?
yuyays
0
24
Webレンダリングの変化とどれ使うん
yuyays
0
110
Featured
See All Featured
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
How to train your dragon (web standard)
notwaldorf
97
6.8k
The Cult of Friendly URLs
andyhume
79
7k
Balancing Empowerment & Direction
lara
6
1.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
540
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Building an army of robots
kneath
307
47k
Visualization
eitanlees
153
17k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
340
Transcript
Racket 言語かんたん解説 Akarenga35 LT by @yuyays
話すこと • racket 言語の説明 • 大切なコンセプト (list, match, cond) •
その他のトピック
背景 • 前回関数型で刺激を受けたのと • racket 言語の復習してみようを思った
racket 言語 • 関数型 • 静的型付けも利用可能(Typed Racket) • DrRacket と呼ばれる開発環境
• lisp 系統 ( カギカッコ ) • Parser, interpreter( パ ー サ ー インタプリタも書ける )
Linked list での比較 class Node: def __init__(self, data, next=None): self.data
= data self.next = next Node(8, Node(4,None)) (struct Node ([data: real) [ next: numlist] (define-type Numlist(U Node `mt)) Node(8, Node(4,`mt)) cons(8 (cons 4 `())
大切なコンセプト (list, match, cond)
List • 基本的にすべてのデ ー タは Immutable(変更不可)なので再起で回してアクセスして料理する • Cons, `( バッククォ
ー ト ) を使用 • `() 空のリスト • 例) • (cons 1 '()) ; => '(1) • (cons 1 (cons 2 '())) ; => '(1 2) • (cons 'a (cons 'b '())) ; => '(a b) • (cons 1 (cons (list 2 3) (cons 4 '()))) ; => '(1 (2 3) 4) • `(1 2 3) ; => '(1 2 3) • `(a b c) ; => '(a b c) • (list 1 2 3)
Match • リスト構造体その他のデ ー タ型を分解するためのパタ ー ンマッ チ • 例)文字列の逆順にして連結を求める関数
• [“ball”, juice”] -> “juiceball (define (rev-str-app [L : (Listof String)]) : String (match L [`() ""] [(cons f r) (string-append(rev-str-app r) f)]))
(define (rev-str-app [L : (Listof String)]) : String (match L
[`() ""] [(cons f r) (string-append(rev-str-app r) f)])) [`() ""] -> もしリストが空なら , からのリストを返す [(cons f r) (string-append(rev-str-app r) f)])) cons(f r) では与えられたリスト L が最初のアイテム fと残りのアイテム r に destructure(取り出されている) それで cons(f r) でリストがそのような形にあてはまるなら , string-append というライブラリ関数に rev-str-app にrを与えたものをfに連結する
python と比較 def rev_str_app(L: list[str]) -> str: if L ==
[]: return "" else: f, *r = L return rev_str_app(r) + f
condition • 条件 (if, else, when 等 ) • 例)リストと数値
n を受け取り 、 リストの最初の n 個の要素を返す関数 • `(`a `b `c `d) 2) -> `(`a `b)) (define (my-take [L : (Listof Any)] [n : Real]) : (Listof Any) (cond [(empty? L) `()] [(= n 0) `()] [(< (length L) n ) L] [else (cons (first L) (my-take (rest L) (- n 1)))]))
• (check-equal? (my-take `(11 22 33 44) 2) `(11 22))
• (check-equal? (my-take `(`a `b `c `d) 2) `(`a `b)) • (check-equal? (my-take `(`a `b `c `d) 100) `(`a `b `c `d)) • (check-equal? (my-take `() 21) `())
関連トピック • AST(abtact sysntax tree) • S-expression(sエクスプレッション ) • scope(
スコ ー プ ) • Box type(mutable 可 ) • Higher order fucntion( 高級関数 ) • Clousure( クロ ー ジャ ) • Function as a value( 関数としての値 ) • binding( バインディング )
参照 • https://racket-lang.org/