From 88619a332e848dc81559d8ac46c6c8b63bbcf9be Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 19 Mar 2021 11:12:26 -0700 Subject: [PATCH] sequences: simplify flip using fry and map-reduce. --- core/sequences/sequences.factor | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 3099c59180..9d5df6a51c 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -1143,24 +1143,15 @@ PRIVATE> - ] keep - [ [ nth-unsafe ] with { } map-as ] curry { } map-as ; inline + [ [ length ] [ min ] map-reduce ] keep + '[ _ [ nth-unsafe ] with { } map-as ] { } map-integers ; inline USE: arrays -: array-length ( array -- len ) - { array } declare length>> ; inline - : array-flip ( matrix -- newmatrix ) { array } declare - [ - [ first-unsafe array-length 1 ] keep - [ array-length min ] (each) (each-integer) - ] keep - [ [ { array } declare array-nth ] with { } map-as ] curry { } map-as ; + [ [ { array } declare length>> ] [ min ] map-reduce ] keep + '[ _ [ { array } declare array-nth ] with { } map-as ] { } map-integers ; PRIVATE> -- 2.34.1