aboutsummaryrefslogtreecommitdiff
path: root/src/r0.bqn
blob: eaac871c3ef96153d5fc9a69417e1ef03152a533 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
# BQN runtime part 0. Requires:
#   Fill _fillBy_
#   +-×⌊=≤≢⥊⊑↕⌜⊘
# Provides:
#   ⌊⌈|<>≠≥⊢⊣∾⋈↑↓⊏˙˜¨´∘○⊸⟜◶⍟
#   ^^^^^^^  ^^^^^  ^^    ^^ are limited, suitable for r1

  {𝕩}
  {𝕩}{𝕨}
˙  {𝕩𝕗}
˜  {𝕩𝔽𝕨𝕩}
  {𝔽𝕨𝔾𝕩}
  {(𝔾𝕨)𝔽𝔾𝕩}
  {(𝔽𝕨𝕩)𝔾𝕩}
  {(𝕨𝕩)𝔽𝔾𝕩}
  {𝕨((𝕨𝔽𝕩)𝕘){𝔽}𝕩}     # LIMITED to number left operand result
  {𝕨((𝕨𝔾𝕩)⊑⊢𝕗){𝔽}𝕩}   # LIMITED to boolean right operand result

Box  {𝕩Fill⟨⟩𝕩}
# LIMITED to numeric arguments for arithmetic cases
             ˜
<  Box       (1-≥)
>             (1-≤)
           (⊣-≥×-)
  --     (⊣-≤×-)
|  0-
  (0<=)10⊑≢  # LIMITED to monadic case

  {𝕩}  {𝕨,𝕩}                # LIMITED by not having a result fill
  {k𝕨k𝕨-k𝕩˜k+≠𝕩}  # LIMITED to two list arguments
  {𝕩𝕨}                       # LIMITED to number 𝕨 and list 𝕩
  {(𝕨+⊑𝕩˙)(𝕩)-𝕨}             # LIMITED to number 𝕨 and list 𝕩

¨  { d𝕩(𝕩)((𝕨)𝔽⊑d)↕≠d } # LIMITED to equal-shape arrays

_fold0{
  l𝕩  F𝔽
  r𝕨 {ll-1l𝕩} 𝕩
  ({r𝕩 F r}(l-1)-⊑𝕩˙)l
  r
}
´  _fold0    # LIMITED to nonempty list 𝕩, or 𝕨 and list 𝕩

GetCells(1==){
  c1×´s1↓≢𝕩
  (c×𝕨)(+⊑(𝕩)˙)s⥊↕c
}{
  𝕩𝕨
} _fillBy_ 
  GetCells  # LIMITED to depth-1 natural number left argument