...
1#! /usr/bin/env bqn
2
3# From BQN documentation / quick start:
4# https://mlochbaum.github.io/BQN/doc/quick.html
5
6# Case conversion utilities
7case ← {
8 diff ← -´ "Aa"
9 Lower ⇐ -⟜diff
10 Upper ⇐ Lower⁼
11}
12
13hw ← <˘ 2‿∘ ⥊ "helloworld"
14hw case.Upper⌾(⊑¨)↩
15•Out hw ↩ ∾ ⥊⍉ [hw, ", "‿"!"] # Hello, World!
16
17# Split at spaces and repeated characters
18Split ← {
19 !1==𝕩 ⋄ (!2=•Type)¨𝕩
20 Proc ← {
21 · 𝕊 ' ': spl⇐1 ; # Space: break and delete it
22 prev Fn cur: ⟨spl,str⟩⇐
23 spl←0 ⋄ str←⟨cur⟩ # Include and don't break...
24 { prev=cur ? spl+↩1 ; @ } # except at equal characters
25 }
26 GV‿GS ← {𝕏¨}¨ ⟨ {⟨s⇐str⟩:s;""}
27 {𝕩.spl} ⟩
28 r ← Proc{»𝔽¨⊢} 𝕩
29 (∾¨ GV ⊔˜ ·+`GS) r
30}
31•Show Split hw # ⟨ "Hel" "lo," "World!" ⟩
View as plain text