# nice way to write (define) Slices in R7RS ?

11 views

### Hen Hanna

Jun 18, 2022, 9:37:32 PMJun 18
to
this is Slices in Gauche... what 's a nice way to write (define) it ?

(define a '(a b c d e f g h i j k l m n o p q r s t u v w x y z))

(slices a 2) --> ((a b) (c d) (e f) (g h) (i j) (k l) (m n) (o p) (q r) (s t) (u v) (w x) (y z))

(slices a 3) --> ((a b c) (d e f) (g h i) (j k l) (m n o) (p q r) (s t u) (v w x) (y z))

(slices a 4) --> ((a b c d) (e f g h) (i j k l) (m n o p) (q r s t) (u v w x) (y z))

(slices a 5) --> ((a b c d e) (f g h i j) (k l m n o) (p q r s t) (u v w x y) (z))

### Paul Rubin

Jun 18, 2022, 10:19:07 PMJun 18
to
Hen Hanna <henh...@gmail.com> writes:
> this is Slices in Gauche... what 's a nice way to write (define) it ?

These start to sound like homework problems? What have you tried?

### Hen Hanna

Jun 19, 2022, 1:03:44 AMJun 19
to
(not homework)

what i'd do... use DO and var RES,
get a slice with Take and push it onto RES
recurse down using Drop

at the end , return (reverse! res)

------------ if there's another way taht's clever, interesting, .... pls let me know !!!