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

    From Hen Hanna@21:1/5 to All on Sat Jun 18 18:37:29 2022
    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))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to Hen Hanna on Sat Jun 18 19:19:04 2022
    Hen Hanna <henhanna@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?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hen Hanna@21:1/5 to Hen Hanna on Sat Jun 18 22:03:41 2022
    On Saturday, June 18, 2022 at 6:37:32 PM UTC-7, Hen Hanna wrote:
    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))


    (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 !!!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)