mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Port before_v0.60/math
, before_v0.60/parsing
and before_v0.60/git
(#844)
This PR is part of porting all old scripts #221 and includes a set of small modules: - `math` - `parsing` - `git`
This commit is contained in:
parent
429126f3d8
commit
15cb7179e2
7 changed files with 9 additions and 46 deletions
21
modules/parsing/sample_andres.nu
Normal file
21
modules/parsing/sample_andres.nu
Normal file
|
@ -0,0 +1,21 @@
|
|||
def look_for [word] {
|
||||
open sample_andres.json |
|
||||
flatten |
|
||||
flatten |
|
||||
insert comp {
|
||||
get shoes_name |
|
||||
split row " " |
|
||||
enumerate | each {
|
||||
[[idx, loc]; [$in.index, ($in.item | str index-of $word)]]
|
||||
} | flatten
|
||||
} |
|
||||
flatten |
|
||||
where comp.loc >= 0 |
|
||||
flatten |
|
||||
update idx { $in + 1 } |
|
||||
reject name price loc |
|
||||
rename nameWords targetWordIndex
|
||||
}
|
||||
|
||||
print (look_for "leather" | to json --indent 4)
|
||||
print (look_for "low-top" | to json --indent 4)
|
Loading…
Add table
Add a link
Reference in a new issue