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
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
960
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Quine, Polyglot, 良いコード
qnighy
4
650
Ethereum_.pdf
nekomatu
0
460
RubyLSPのマルチバイト文字対応
notfounds
0
120
Remix on Hono on Cloudflare Workers
yusukebe
1
300
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Featured
See All Featured
Thoughts on Productivity
jonyablonski
67
4.3k
RailsConf 2023
tenderlove
29
900
Building Adaptive Systems
keathley
38
2.3k
Embracing the Ebb and Flow
colly
84
4.5k
Agile that works and the tools we love
rasmusluckow
327
21k
Facilitating Awesome Meetings
lara
50
6.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
How GitHub (no longer) Works
holman
310
140k
For a Future-Friendly Web
brad_frost
175
9.4k
A designer walks into a library…
pauljervisheath
204
24k
It's Worth the Effort
3n
183
27k
BBQ
matthewcrist
85
9.3k
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!