## ~jshholland/trybqn

trybqn/2013.bqn -rw-r--r-- 1.4 KiB
4e81c000Josh Holland use new ⋈ builtin 5 months ago
`                                                                                `
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37```
```# Write a dfn to produce a vector of the first n odd numbers.
Prob1 ⇐ 1+2×↕

# Write a dfn which returns the percent (from 0 to 100) of passing
Prob2 ⇐ (100×1⌊+´÷≠)65⊸≤

# Write a dfn which returns the number of words [in a] character vector.
Prob3 ⇐ ≠(¬-˜⊢×·+`»⊸>)∘(' '⊸≠)⊔⊢

# Write an APL dfn which returns a 1 if the opening and closing
# parentheses in a character vector are balanced, or a zero otherwise.
Prob4 ⇐ (∧´∘≥⟜0∧0≡·⊑¯1⊸↑)·+`'('⊸=-')'⊸=

# Write an APL dfn which produces an n×n identity matrix.
Prob5 ⇐ ≍˜ ⥊ 1∾⥊⟜0
# BQNcrate suggests the shorter and slightly less magical =⌜˜↕
# This solution is quite a bit asymptotically faster, at least
# according to extremely unscientific testing with •_timed.

# Write a dfn which returns the magnitude of the range (i.e. the
# difference between the lowest and highest values) of a numeric array.
Prob6 ⇐ (⌈´-⌊´)⥊

# Write a dfn which selects the floating point (non-integer) numbers
# from a numeric vector.
Prob7 ⇐ (⌊≠⊢)⊸/

# Write a dfn which produces a multiplication table.
Prob8 ⇐ ×⌜˜1+↕

# Write a dfn which produces n month moving averages for a year’s
# worth of data.
Prob9 ⇐ (+´÷≠)˘↕

# Write a dfn which solves a linear system.
# Prob10 ⇐ +˝∘×⎉1‿∞⁼
```