Skip to content

Commit

Permalink
✨ add ḳ (keep); addresses part of #3
Browse files Browse the repository at this point in the history
  • Loading branch information
codereport committed Feb 29, 2024
1 parent 0def39d commit 9e1db7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The intending way of using Jellyfish is through the [Jello REPL](https://github.
* `` (Q's `prior`)
* `É` (dual to `odd?` i.e. `even?`)
* `` (`bits` aka `bit_count`, `pop_count` or `ones_count`)
* `` (Uiua's `keep` and BQN/APL's `compress`/`replicate`)

### Changes

Expand Down
11 changes: 9 additions & 2 deletions jelly/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

code_page = '''¡¢£¤¥¦©¬®µ½¿€ÆÇÐÑ×ØŒÞßæçðıȷñ÷øœþ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¶''' # noqa: Q001 W605
code_page += '''°¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ƁƇƊƑƓƘⱮƝƤƬƲȤɓƈɗƒɠɦƙɱɲƥʠɼʂƭʋȥẠḄḌẸḤỊḲḶṂṆỌṚṢṬỤṾẈỴẒȦḂĊḊĖḞĠḢİĿṀṄȮṖṘṠṪẆẊẎŻạḅḍẹḥịḳḷṃṇọṛṣṭ§Äẉỵẓȧḃċḋėḟġḣŀṁṅȯṗṙṡṫẇẋẏż«»‘’“”''' # noqa: Q001
code_page += "ṕṔÉ①" # jellyfish specific
code_page += "ṕṔÉ①" # jellyfish specific

# Unused symbols for single-byte atoms/quicks: (quƁƘȤėɦɱɲƥʠʂȥḥḳṇẉỵẓġṅẏ
# Unused symbols for single-byte atoms/quicks: (quƁƘȤėɦɱɲƥʠʂȥḥṇẉỵẓġṅẏ

str_digit = "0123456789"
str_lower = "abcdefghijklmnopqrstuvwxyz"
Expand Down Expand Up @@ -370,6 +370,9 @@ def partition(array):
array = iterable(array, make_digits = True)
return list(filter(lambda x: x[0] > 0, group_equal(array)))

def keep(mask, array):
return [val for val, m in zip(array, mask) if m]

def group_lengths(array):
array = iterable(array, make_digits = True)
lengths = []
Expand Down Expand Up @@ -1614,6 +1617,10 @@ def zip_ragged(array):
arity = 2,
call = lambda x, y: partition_at(x, y, border = 2)
),
"ḳ": attrdict(
arity = 2,
call = lambda x, y: keep(x, y)
),
"L": attrdict(
arity = 1,
call = lambda z: len(iterable(z))
Expand Down

0 comments on commit 9e1db7d

Please sign in to comment.