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
95
Rust - Lightning Talk
litonico
0
160
Other Decks in Programming
See All in Programming
CSC509 Lecture 09
javiergs
PRO
0
140
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
3
240
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
CSC509 Lecture 12
javiergs
PRO
0
160
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
260
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
Macとオーディオ再生 2024/11/02
yusukeito
0
380
Jakarta EE meets AI
ivargrimstad
0
260
Quine, Polyglot, 良いコード
qnighy
4
650
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
GitHub's CSS Performance
jonrohan
1030
460k
Ruby is Unlike a Banana
tanoku
97
11k
How STYLIGHT went responsive
nonsquared
95
5.2k
4 Signs Your Business is Dying
shpigford
180
21k
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!