[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Splitting an array

William James

11/9/2015 3:41:00 PM

Group the numbers in an array. Create a new group whenever
a number is less than the previous number.

MatzLisp (Ruby):

Note: works under Ruby 2.2, but Ruby 2.0 lacks slice_when.

[0,2,3,2,4,9,8,8,1,6,5].slice_when{|a,b| a>b}
===>
[[0, 2, 3], [2, 4, 9], [8, 8], [1, 6], [5]]

I imagine that a version in CL (COBOL-Like) would be
very prolix and inelegant.