Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nice way to write (define) Slices in R7RS ?

13 views
Skip to first unread message

Hen Hanna

unread,
Jun 18, 2022, 9:37:32 PM6/18/22
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

unread,
Jun 18, 2022, 10:19:07 PM6/18/22
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

unread,
Jun 19, 2022, 1:03:44 AM6/19/22
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 !!!
0 new messages