pyvm: split op handlers into ops_core/ops_box/ops_ctrl; add ops_flow + intrinsic; delegate vm.py without behavior change
net-plugin: modularize constants (consts.rs) and sockets (sockets.rs); remove legacy commented socket code; fix unused imports mir: move instruction unit tests to tests/mir_instruction_unit.rs (file lean-up); no semantic changes runner/pyvm: ensure using pre-strip; misc docs updates Build: cargo build ok; legacy cfg warnings remain as before
This commit is contained in:
36
apps/libs/array_ext.nyash
Normal file
36
apps/libs/array_ext.nyash
Normal file
@ -0,0 +1,36 @@
|
||||
// ArrayExtBox: tiny helpers for arrays
|
||||
static box ArrayExtBox {
|
||||
each(arr, fn) {
|
||||
local i = 0
|
||||
local n = arr.size()
|
||||
loop (i < n) { fn(arr.get(i), i) i = i + 1 }
|
||||
return arr
|
||||
}
|
||||
map(arr, fn) {
|
||||
local out = []
|
||||
local i = 0
|
||||
local n = arr.size()
|
||||
loop (i < n) { out.push(fn(arr.get(i))) i = i + 1 }
|
||||
return out
|
||||
}
|
||||
filter(arr, fn) {
|
||||
local out = []
|
||||
local i = 0
|
||||
local n = arr.size()
|
||||
loop (i < n) {
|
||||
local v = arr.get(i)
|
||||
if fn(v) { out.push(v) }
|
||||
i = i + 1
|
||||
}
|
||||
return out
|
||||
}
|
||||
join(arr, delim) {
|
||||
local n = arr.size()
|
||||
if n == 0 { return "" }
|
||||
local s = arr.get(0)
|
||||
local i = 1
|
||||
loop (i < n) { s = s + delim + arr.get(i) i = i + 1 }
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user