Skip to content

Commit

Permalink
Use list
Browse files Browse the repository at this point in the history
  • Loading branch information
anttih committed Oct 30, 2023
1 parent 1f6d288 commit d18f073
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Data/Array/NonEmpty/Internal.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(export foldr1Impl
foldl1Impl
traverse1Impl)
(import (only (rnrs base) define lambda cons let if quote)
(import (only (rnrs base) define lambda list cons let if quote)
(only (chezscheme) fx- fx< fx>= fx+)
(prefix (purs runtime lib) rt:)
(prefix (purs runtime srfi :214) srfi:214:))
Expand All @@ -26,12 +26,11 @@
(lambda (apply map f)

(define kons (lambda (x) (lambda (ys) (cons x ys))))
(define singleton (lambda (x) (cons x '())))

(lambda (array)
((map srfi:214:list->flexvector)
(srfi:214:flexvector-fold-right
(lambda (s x) ((apply ((map kons) (f x))) s))
((map singleton) (f (srfi:214:flexvector-back array)))
((map list) (f (srfi:214:flexvector-back array)))
(srfi:214:flexvector-copy array 0 (fx- (rt:array-length array) 1)))))))
)

0 comments on commit d18f073

Please sign in to comment.