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
LLM生成文章の精度評価自動化とプロンプトチューニングの効率化について
layerx
PRO
2
130
僕がつくった48個のWebサービス達
yusukebe
18
17k
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
PagerDuty を軸にした On-Call 構築と運用課題の解決 / PagerDuty Japan Community Meetup 4
horimislime
1
110
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
250
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
410
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
16
4k
Pinia Colada が実現するスマートな非同期処理
naokihaba
2
160
Vue SFCのtemplateでTypeScriptの型を活用しよう
tsukkee
3
1.5k
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.4k
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.6k
Typedesign – Prime Four
hannesfritz
39
2.4k
Into the Great Unknown - MozCon
thekraken
31
1.5k
We Have a Design System, Now What?
morganepeng
50
7.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Happy Clients
brianwarren
97
6.7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Faster Mobile Websites
deanohume
304
30k
Documentation Writing (for coders)
carmenintech
65
4.4k
BBQ
matthewcrist
85
9.3k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
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!