| 1 | <h2>Examples From Rosetta Code</h2> |
| 2 | <h3>100 Doors</h3> |
| 3 | <pre><code> |
| 4 | swch ← ≠´{100⥊1«𝕩⥊0}¨1+↕100 |
| 5 | ¯1↓∾{𝕩∾@+10}¨•Fmt¨⟨swch,/swch⟩ |
| 6 | </code></pre> |
| 7 | <h3>Archimedean Spiral</h3> |
| 8 | <pre><code> |
| 9 | {(•math.Sin •Plot○(⊢×↕∘≠) •math.Cos) -(2×π) × 𝕩⥊(↕÷-⟜1)100} |
| 10 | </code></pre> |
| 11 | <h3>Damm Algorithm</h3> |
| 12 | <pre><code> |
| 13 | table ← >⟨ 0‿3‿1‿7‿5‿9‿8‿6‿4‿2 |
| 14 | 7‿0‿9‿2‿1‿5‿4‿8‿6‿3 |
| 15 | 4‿2‿0‿6‿8‿7‿1‿3‿5‿9 |
| 16 | 1‿7‿5‿0‿9‿8‿3‿4‿2‿6 |
| 17 | 6‿1‿2‿3‿0‿4‿5‿9‿7‿8 |
| 18 | 3‿6‿7‿4‿2‿0‿9‿5‿8‿1 |
| 19 | 5‿8‿6‿9‿7‿2‿0‿1‿3‿4 |
| 20 | 8‿9‿4‿5‿3‿6‿2‿0‿1‿7 |
| 21 | 9‿4‿3‿8‿6‿1‿7‿2‿0‿5 |
| 22 | 2‿5‿8‿1‿4‿3‿6‿7‿9‿0 ⟩ |
| 23 | |
| 24 | |
| 25 | Digits ← 10{⌽𝕗|⌊∘÷⟜𝕗⍟(↕1+·⌊𝕗⋆⁼1⌈⊢)} |
| 26 | |
| 27 | Damm ← {0=0(table⊑˜⋈)˜´⌽Digits 𝕩} |
| 28 | |
| 29 | Damm¨5724‿5727‿112946 |
| 30 | </code></pre> |
| 31 | <h3>Knuth/Fisher-Yates Shuffle</h3> |
| 32 | <pre><code> |
| 33 | Knuth ← { |
| 34 | 𝕊 arr: |
| 35 | l ← ≠arr |
| 36 | { |
| 37 | arr ↩ ⌽⌾(⟨•rand.Range l, 𝕩⟩⊸⊏)arr |
| 38 | }¨↕l |
| 39 | arr |
| 40 | } |
| 41 | P ← •Show Knuth |
| 42 | |
| 43 | P ⟨⟩ |
| 44 | P ⟨10⟩ |
| 45 | P ⟨10, 20⟩ |
| 46 | P ⟨10, 20, 30⟩ |
| 47 | </code></pre> |
| 48 | <h2>Comments</h2> |
| 49 | <pre><code>#!/usr/bin/env bqn |
| 50 | # Full Line Comment |
| 51 | '#' # The preceding should not be a comment. |
| 52 | "BQN is #1" # The preceding should not be a comment. |
| 53 | 1 + 1 # Comment at End of Line. |
| 54 | </code></pre> |
| 55 | |
| 56 | <h2>Literals</h2> |
| 57 | <pre><code> |
| 58 | "String Literal" |
| 59 | 'c' |
| 60 | """There is a double quote at the start of this string." |
| 61 | "'c'" |
| 62 | # "Comment, not String" |
| 63 | "String, # Not Comment" |
| 64 | @ |
| 65 | </code></pre> |
| 66 | |
| 67 | <h2>Tokens</h2> |
| 68 | <h3>Primitive Functions</h3> |
| 69 | <pre><code> |
| 70 | +-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔! |
| 71 | </code></pre> |
| 72 | <h3>1-Operators</h3> |
| 73 | <pre><code> |
| 74 | ˙˜˘¨⌜⁼´˝` |
| 75 | </code></pre> |
| 76 | <h3>2-Operators</h3> |
| 77 | <pre><code> |
| 78 | ∘○⊸⟜⌾⊘◶⎉⚇⍟⎊ |
| 79 | </code></pre> |
| 80 | <h3>Special Names</h3> |
| 81 | <pre><code> |
| 82 | 𝕨𝕩𝕗𝕘𝕤𝕎𝕏𝔽𝔾𝕊𝕣_𝕣 |
| 83 | _𝕣_ |
| 84 | </code></pre> |
| 85 | <h3>Punctuation</h3> |
| 86 | <pre><code> |
| 87 | ←⇐↩(){}⟨⟩[]‿·⋄,.;:? |
| 88 | </code></pre> |
| 89 | |
| 90 | <h2>Words</h2> |
| 91 | <h3>Numbers</h3> |
| 92 | <pre><code> |
| 93 | 1464 |
| 94 | 3.14159 |
| 95 | ¯2 |
| 96 | ∞ |
| 97 | π |
| 98 | ¯∞ |
| 99 | 2.8e¯4 |
| 100 | 1.618E2 |
| 101 | </code></pre> |
| 102 | <h3>Names</h3> |
| 103 | <pre><code> |
| 104 | VariableName |
| 105 | ThereAre4Symbols_¯∞πAllowedInNames |
| 106 | </code></pre> |
| 107 | <h2>Namespaces</h2> |
| 108 | <pre><code> |
| 109 | example.b |
| 110 | {n⇐7}.n |
| 111 | </code></pre> |
| 112 | <h2>System Functions</h2> |
| 113 | <pre><code> |
| 114 | •Function |
| 115 | •function |
| 116 | •_function_ |
| 117 | @•Function@ |
| 118 | +•Function+ |
| 119 | ˙•Function˙ |
| 120 | ∘•Function∘ |
| 121 | 𝕨•Function𝕩 |
| 122 | ←•Function? |
| 123 | •Function_.¯∞πCanHaveSymbols |
| 124 | •0.0.0.0 |
| 125 | </code></pre> |