Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by Arunbear (Parson)
on Feb 11, 2011 at 19:52 UTC ( #887670=note: print w/ replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

Another Lisp variant:

#lang scheme (require scheme/string) (define (chunky li sz [str ""]) (let ([graft (lambda (s l) (string-append s (string-join l " ") "\n"))]) (if [<= (length li) sz] (graft str li) (let-values ([(x y) (split-at li sz)]) (chunky y sz (graft str x)))))) (display (chunky '("a" "bb" "c" "d" "e" "f" "g" "h") 3))
+% mzscheme chunky.ss a bb c d e f g h +%


Comment on Re: Rosetta code: Split an array into chunks
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2015-07-06 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls