Langton's ant: Difference between revisions

add BQN
(add BQN)
Line 803:
####
##</pre>
 
=={{header|BQN}}==
<code>Ant</code> is the main function, which runs the ant simulation given a starting point, direction and grid of zeros.
 
<code>Fmt</code> then formats into hashes and spaces.
 
<code>_while_</code> is an idiom from [https://mlochbaum.github.io/bqncrate/ BQNcrate] which helps with conditional looping.
 
<lang bqn>Rot ← ¬⊸{-⌾(𝕨⊸⊑)⌽𝕩}
Fmt ← {𝕩⊑" #"}¨
_while_ ← {𝔽⍟𝔾∘𝔽_𝕣_𝔾∘𝔽⍟𝔾𝕩}
 
Ant ← 2⊑{ # Generator Block
p‿d‿g:
rot ← d Rot˜ p⊑g
p + rot
rot
¬⌾(p⊸⊑)g
} _while_ { # Condition Block
p‿d‿g:
∧´(p≥0‿0)∧p<≢g
}
 
•Show Fmt Ant ⟨50‿50, 0‿1, 100‿100⥊0⟩</lang>
 
[https://mlochbaum.github.io/BQN/try.html#code=Um90IOKGkCDCrOKKuHst4oy+KPCdlajiirjiipEp4oy98J2VqX0KRm10IOKGkCB78J2VqeKKkSIgIyJ9wqgKX3doaWxlXyDihpAge/CdlL3ijZ/wnZS+4oiY8J2UvV/wnZWjX/CdlL7iiJjwnZS94o2f8J2UvvCdlal9CgpBbnQg4oaQIDLiipF7ICMgR2VuZXJhdG9yIEJsb2NrCiAgcOKAv2TigL9nOgogIHJvdCDihpAgZCBSb3TLnCBw4oqRZwogIOKfqAogICAgcCArIHJvdAogICAgcm90CiAgICDCrOKMvihw4oq44oqRKWcKICDin6kKfSBfd2hpbGVfIHsgICAjIENvbmRpdGlvbiBCbG9jawogIHDigL9k4oC/ZzoKICDiiKfCtChw4omlMOKAvzAp4oincDziiaJnCn0KCuKAolNob3cgRm10IEFudCDin6g1MOKAvzUwLCAw4oC/MSwgMTAw4oC/MTAw4qWKMOKfqQo= Try It!] (Displaying the result takes some time due to JS, ≈40 secs on my machine)
 
 
=={{header|C}}==
236

edits