Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Botany with Bytes
Search
Lito Nicolai
April 14, 2015
Programming
0
320
Botany with Bytes
Botany with Bytes, for LA Ruby Conf 2015 and RubyConf 2015!
(Video coming soon)
Lito Nicolai
April 14, 2015
Tweet
Share
More Decks by Lito Nicolai
See All by Lito Nicolai
How Phones Do
litonico
0
110
The Voldemort Effect
litonico
1
510
Rainbows! Color Theory for Computers - RubyConf 2016
litonico
1
140
Rainbows (Lightning Talk)
litonico
0
96
Rust - Lightning Talk
litonico
0
160
Other Decks in Programming
See All in Programming
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
103 Early Hints
sugi_0000
1
230
Spatial Rendering for Apple Vision Pro
warrenm
0
110
CSC305 Lecture 26
javiergs
PRO
0
140
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
840
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
return文におけるstd::moveについて
onihusube
1
1.2k
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
3
480
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
480
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
169
14k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
The Cult of Friendly URLs
andyhume
78
6.1k
RailsConf 2023
tenderlove
29
940
Docker and Python
trallard
42
3.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Faster Mobile Websites
deanohume
305
30k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Transcript
RubyConf 2015 - Lito Nicolai - @lito_nico Botany Bytes with
Lito Nicolai
RubyConf 2015 - Lito Nicolai - @lito_nico This talk uses
graphics! $ gem install --pre graphics
RubyConf 2015 - Lito Nicolai - @lito_nico Imagine you’re algae…
RubyConf 2015 - Lito Nicolai - @lito_nico An alga (you)
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico A A B
A B A A B A A B A B A A B A B A A B A A B A B A A B A A B incidentally, Fibonacci
RubyConf 2015 - Lito Nicolai - @lito_nico Aristid Lindenmayer Genus
Species
RubyConf 2015 - Lito Nicolai - @lito_nico Aristid Lindenmayer Genus
Species
RubyConf 2015 - Lito Nicolai - @lito_nico “L-Systems” Start: A
Rules: A ! AB B ! A
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico Rewriting Systems String
Line Grid A AB ABA ABAAB ABAABABA
RubyConf 2015 - Lito Nicolai - @lito_nico This is a
grammar!
RubyConf 2015 - Lito Nicolai - @lito_nico What’s a grammar?
RubyConf 2015 - Lito Nicolai - @lito_nico What strings can
you make with rules? Montana State University Mathematics (grids, lines… things) A ! AB B ! A
RubyConf 2015 - Lito Nicolai - @lito_nico What strings can
you match with these rules? -?(\d+(\.\d+)?|\.\d+)([eE][+-]?\d+)?
RubyConf 2015 - Lito Nicolai - @lito_nico Where do L-Systems
fit in here?
RubyConf 2015 - Lito Nicolai - @lito_nico Organizing Grammars RegEx
Lindenmayer & Prusinkiewicz (needs a DFA) (using computers)
RubyConf 2015 - Lito Nicolai - @lito_nico (let’s ignore finite
grammars) RegEx Lindenmayer & Prusinkiewicz
RubyConf 2015 - Lito Nicolai - @lito_nico RegEx HTML Lindenmayer
& Prusinkiewicz Chomsky Hierarchy (needs a stack)
RubyConf 2015 - Lito Nicolai - @lito_nico RegEx HTML Lindenmayer
& Prusinkiewicz C++ Chomsky Hierarchy (needs RAM)
RubyConf 2015 - Lito Nicolai - @lito_nico RegEx HTML Lindenmayer
& Prusinkiewicz Chomsky Hierarchy C++
RubyConf 2015 - Lito Nicolai - @lito_nico Ruby? RegEx HTML
Lindenmayer & Prusinkiewicz Chomsky Hierarchy C++
RubyConf 2015 - Lito Nicolai - @lito_nico Chomsky Hierarchy Ruby?
RegEx HTML Perl Lindenmayer & Prusinkiewicz C++
RubyConf 2015 - Lito Nicolai - @lito_nico Chomsky Hierarchy RegEx
HTML Perl Lindenmayer & Prusinkiewicz Ruby? C++
RubyConf 2015 - Lito Nicolai - @lito_nico Chomsky Hierarchy RegEx
HTML Perl Lindenmayer & Prusinkiewicz Ruby? C++
RubyConf 2015 - Lito Nicolai - @lito_nico L-Systems are a
strange slice of other grammars!
RubyConf 2015 - Lito Nicolai - @lito_nico ((((((X)))))) Can match
this ^ (regex can’t match either) Nested Balanced Parens ((((((())))))) But not this ^
RubyConf 2015 - Lito Nicolai - @lito_nico class LSystem attr_reader
:state def initialize state, rules @state = state @rules = rules end def step @state = @state.split("") .map {|s| @rules[s] } .join self end end
RubyConf 2015 - Lito Nicolai - @lito_nico class LSystem attr_reader
:state def initialize state, rules @state = state @rules = rules end def step @state = @state.split("") .map {|s| @rules[s] } .join self end end
RubyConf 2015 - Lito Nicolai - @lito_nico @state = @state.split("")
.map {|s| @rules[s] } .join "AB" "A" "B" "AB" "A" "ABA" split apply rules join
RubyConf 2015 - Lito Nicolai - @lito_nico > l =
LSystem.new "A", "A" => "AB", "B" => "A" > l.step => "AB" > l.step => "ABA" > l.step => "ABAAB" > l.step => "ABAABABA"
RubyConf 2015 - Lito Nicolai - @lito_nico All in a
line
RubyConf 2015 - Lito Nicolai - @lito_nico More Dimensions!
RubyConf 2015 - Lito Nicolai - @lito_nico Leaf ! Stem
LeftLeaf RightLeaf Stem ! Stem Stem Sprout
RubyConf 2015 - Lito Nicolai - @lito_nico Turtle Graphics
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico turtle.forward
RubyConf 2015 - Lito Nicolai - @lito_nico turtle.push
RubyConf 2015 - Lito Nicolai - @lito_nico turtle.left 90
RubyConf 2015 - Lito Nicolai - @lito_nico turtle.forward
RubyConf 2015 - Lito Nicolai - @lito_nico turtle.pop
RubyConf 2015 - Lito Nicolai - @lito_nico Turtle Evaluation
RubyConf 2015 - Lito Nicolai - @lito_nico > turtle =
Turtle.new “S[S", "S" => :forward, "L" => :forward, "[" => [:left, 60], "]" => [:right, 60], "." => :push, "," => :pop
RubyConf 2015 - Lito Nicolai - @lito_nico > turtle =
Turtle.new “S[S", "S" => :forward, "L" => :forward, "[" => [:left, 60], "]" => [:right, 60], "." => :push, "," => :pop
RubyConf 2015 - Lito Nicolai - @lito_nico > turtle =
Turtle.new “S[S", "S" => :forward, "L" => :forward, "[" => [:left, 60], "]" => [:right, 60], "." => :push, "," => :pop
RubyConf 2015 - Lito Nicolai - @lito_nico > turtle =
Turtle.new “S[S", "S" => :forward, "L" => :forward, "[" => [:left, 60], "]" => [:right, 60], "." => :push, "," => :pop
RubyConf 2015 - Lito Nicolai - @lito_nico Leaf ! Stem
LeftLeaf RightLeaf Stem ! Stem Stem Sprout
RubyConf 2015 - Lito Nicolai - @lito_nico “LeftLeaf” SaveState TurnLeft
Leaf . [ L “RightLeaf” RestoreState TurnRight Leaf , ] L At the end of a stem…
RubyConf 2015 - Lito Nicolai - @lito_nico > turtle =
Turtle.new sprout.state, "S" => :forward, "L" => :forward, "[" => [:left, 60], "]" => [:right, 60], "." => :push, "," => :pop > sprout = LSystem.new "L", "L" => “S.[L,]L", "S" => “SS”, "[" => "[", "]" => "]", "." => ".", "," => ","
RubyConf 2015 - Lito Nicolai - @lito_nico First Generation
RubyConf 2015 - Lito Nicolai - @lito_nico L
RubyConf 2015 - Lito Nicolai - @lito_nico Second Generation
RubyConf 2015 - Lito Nicolai - @lito_nico S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico Next Generation
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico SS.[S.[L,]L,]S.[L,]L
RubyConf 2015 - Lito Nicolai - @lito_nico Trees don’t look
like this
RubyConf 2015 - Lito Nicolai - @lito_nico (is what I
used to say) Yes, they really look like this! Drosera Binata var. Multifida
RubyConf 2015 - Lito Nicolai - @lito_nico Juniper Branch Start:
T Rules: T ! T.[T,T.]T,.T,
RubyConf 2015 - Lito Nicolai - @lito_nico Juniper Branch
RubyConf 2015 - Lito Nicolai - @lito_nico Juniper Branch
RubyConf 2015 - Lito Nicolai - @lito_nico Juniper Branch
RubyConf 2015 - Lito Nicolai - @lito_nico Plants are computing
as they grow! That’s super neato!
RubyConf 2015 - Lito Nicolai - @lito_nico L-System Weird Stuff
Start: A Rules: A ! B[A[B B ! A]B]A
RubyConf 2015 - Lito Nicolai - @lito_nico Weird Stuff (there
be dragons)
RubyConf 2015 - Lito Nicolai - @lito_nico A different view
(top-down)
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico Plant growth hormone
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico (Paraphrased from Vi
Hart)
RubyConf 2015 - Lito Nicolai - @lito_nico O(lots) Time complexity:
RubyConf 2015 - Lito Nicolai - @lito_nico (discovered at cambridge)
The very first model: charged particles
RubyConf 2015 - Lito Nicolai - @lito_nico Douady & Couder
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico O(n²) Time complexity:
RubyConf 2015 - Lito Nicolai - @lito_nico btw, Alan Turing
Hypothesis of General Phyllotaxis (…and later, even deeper work)
RubyConf 2015 - Lito Nicolai - @lito_nico Turing’s drawing
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico 137.5
RubyConf 2015 - Lito Nicolai - @lito_nico 360 - (360/φ)
RubyConf 2015 - Lito Nicolai - @lito_nico Start: Stem Rules:
Stem ! Stem Rotate Leaf Leaf ! BiggerLeaf Use an L-System!
RubyConf 2015 - Lito Nicolai - @lito_nico Start: Stem Rules:
Stem ! Stem Rotate Leaf Leaf ! BiggerLeaf
RubyConf 2015 - Lito Nicolai - @lito_nico O(much better!) Time
complexity:
RubyConf 2015 - Lito Nicolai - @lito_nico Back to algae
(in 3D!)
RubyConf 2015 - Lito Nicolai - @lito_nico (you again)
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico Not actually getting
smaller
RubyConf 2015 - Lito Nicolai - @lito_nico Aside: Representing Cells
stackoverflow.com
RubyConf 2015 - Lito Nicolai - @lito_nico …and how they
connect
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico Demo
RubyConf 2015 - Lito Nicolai - @lito_nico Kinds of Surfaces
Flat No Curvature
RubyConf 2015 - Lito Nicolai - @lito_nico Kinds of Surfaces
Spherical Positive Curvature Flat No Curvature
RubyConf 2015 - Lito Nicolai - @lito_nico Kinds of Surfaces
Spherical Positive Curvature Flat No Curvature Hyperbolic Negative Curvature
RubyConf 2015 - Lito Nicolai - @lito_nico Kinds of Surfaces
Spherical Positive Curvature Flat No Curvature Hyperbolic Negative Curvature Plants!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico How many unique
parallel lines? None One Lots!
RubyConf 2015 - Lito Nicolai - @lito_nico
RubyConf 2015 - Lito Nicolai - @lito_nico Thank You!
RubyConf 2015 - Lito Nicolai - @lito_nico I KNEW you
would ask about Perl…
RubyConf 2015 - Lito Nicolai - @lito_nico Lito:~$ perl -E
'sub dunno() { 3 } say dunno + 4'
RubyConf 2015 - Lito Nicolai - @lito_nico Lito:~$ perl -E
'sub dunno() { 3 } say dunno + 4' 7 Lito:~$ _
RubyConf 2015 - Lito Nicolai - @lito_nico Lito:~$ perl -E
'sub dunno() { 3 } say dunno + 4' 7 Lito:~$ perl -E 'sub dunno { 3 } say dunno + 4'
RubyConf 2015 - Lito Nicolai - @lito_nico Lito:~$ perl -E
'sub dunno() { 3 } say dunno + 4' 7 Lito:~$ perl -E 'sub dunno { 3 } say dunno + 4’ 3 Lito:~$ _
RubyConf 2015 - Lito Nicolai - @lito_nico Lito:~$ perl -E
'sub dunno() { 3 } say dunno + 4' 7 Lito:~$ perl -E 'sub dunno { 3 } say dunno + 4’ 3 Lito:~$ _ no args (‘nullary’) some args
RubyConf 2015 - Lito Nicolai - @lito_nico perl -E 'BEGIN
{ *dunno = sub() { 3 } } say dunno + 4'
RubyConf 2015 - Lito Nicolai - @lito_nico perl -E 'BEGIN
{ *dunno = sub() { 3 } } say dunno + 4' BEGIN { *dunno = sub { 3 } } say dunno + 4
RubyConf 2015 - Lito Nicolai - @lito_nico perl -E 'BEGIN
{ *dunno = sub() { 3 } } say dunno + 4' BEGIN { *dunno = sub { 3 } } say dunno + 4 BEGIN { if # SOME_CONDITION *dunno = sub { 3 } else { *dunno = sub() { 3 } } } say dunno + 4 any code!