feat(tvix/eval): implement builtins.partition

Change-Id: I8b591f3057c68c1542046fc5a771973f2238c9df
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7020
Autosubmit: j4m3s <james.landrein@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
James Landrein 2022-10-14 13:49:20 +02:00 committed by clbot
parent 4dcb8f38c2
commit 5ee2258692
3 changed files with 39 additions and 0 deletions

View file

@ -0,0 +1 @@
[ { right = [ 1 2 3 4 5 ]; wrong = [ ]; } { right = [ ]; wrong = [ 1 2 3 4 5 ]; } { right = [ 2 ]; wrong = [ 1 3 4 5 ]; } { right = [ [ 1 2 ] [ 3 4 ] ]; wrong = [ [ 1 ] [ 2 ] [ 3 ] ]; } ]

View file

@ -0,0 +1,13 @@
[
(builtins.partition (_: true) [ 1 2 3 4 5])
(builtins.partition (_: false) [ 1 2 3 4 5])
(builtins.partition (x: x == 2) [ 1 2 3 4 5])
(builtins.partition (x: (builtins.length x) > 1) [
[ 1 ]
[ 1 2 ]
[ 2 ]
[ 3 ]
[ 3 4 ]
])
]