Post Reply 
Programming puzzles: processing lists!
01-28-2019, 11:19 PM
Post: #262
RE: Programming puzzles: processing lists!
(01-28-2019 10:25 PM)John Keith Wrote:  your program reminds me of another useful little program which transforms a list into overlapping sublists

That's partition with step 1 in Clojure:
Code:
user=> (partition 2 1 [1 2 3 4 5])
((1 2) (2 3) (3 4) (4 5))


Code:
user=> (doc partition)
-------------------------
clojure.core/partition
([n coll] [n step coll] [n step pad coll])
  Returns a lazy sequence of lists of n items each, at offsets step
  apart. If step is not supplied, defaults to n, i.e. the partitions
  do not overlap. If a pad collection is supplied, use its elements as
  necessary to complete last partition upto n items. In case there are
  not enough padding elements, return a partition with less than n items.
nil

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - Thomas Klemm - 01-28-2019 11:19 PM



User(s) browsing this thread: 1 Guest(s)