Skip to content

Commit

Permalink
Implement abs/0 filter
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Feb 28, 2024
1 parent 23187ab commit 52bfba1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions prelude.jq
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ def not: if . then false else true end;
def select(f): if f then . else empty end;
def map(f): [.[] | f];
def map_values(f): .[] |= f;
def abs: if . < 0 then - . else . end;

def isfinite: isinfinite | not;
def nulls: select(type == "null");
Expand Down
13 changes: 13 additions & 0 deletions tests/from_manual/functions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
use crate::test;

test!(
abs1,
r#"
map(abs)
"#,
r#"
[-10, -1.1, -1e-1]
"#,
r#"
[10,1.1,1e-1]
"#
);

test!(
length1,
r#"
Expand Down

0 comments on commit 52bfba1

Please sign in to comment.