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
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
430
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
430
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
340
Vue.js学習の振り返り
hiro_xre
2
130
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.2k
役立つログに取り組もう
irof
26
8.7k
Pinia Colada が実現するスマートな非同期処理
naokihaba
2
160
Vue3の一歩踏み込んだパフォーマンスチューニング2024
hal_spidernight
3
3.1k
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.4k
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
3
400
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Writing Fast Ruby
sferik
626
61k
Designing for humans not robots
tammielis
249
25k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Building an army of robots
kneath
302
42k
A Modern Web Designer's Workflow
chriscoyier
692
190k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
How to Ace a Technical Interview
jacobian
275
23k
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!