/usr/lib/group.scm is in scheme9 2013.11.26-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010,2012
; Placed in the Public Domain
;
; (group list integer) ==> list
;
; Group the elements of LIST in tuples of INTEGER elements
; each (except for the last tuple, which may contain fewer
; elements). Return a list of the resulting tuples. The
; elements appear in the output list in the same order as
; in the input list.
;
; INTEGER must be positive.
;
; Example: (group '(1 2 3 4 5) 2) ==> ((1 2) (3 4) (5))
; (group '(1 2 3 4 5) 5) ==> ((1 2 3 4 5))
(load-from-library "take.scm")
(define (group a n)
(let group ((a a)
(k (length a))
(r '()))
(if (< n k)
(group (list-tail a n)
(- k n)
(cons (take a n) r))
(reverse! (cons a r)))))
|