Hi Alan,

`sublist` should be pretty fast. Testing just now, NetLogo took 0.014s to
take 50,000 sublists (length 1 to 50,000) of a 100,000 element list.

Looking at the implementation, it should run in constant time with respect
to the length sublist and `O(log_32(length of the main list))` (`sublist`
pretty much just calls Scala's `Vector.slice`). My own tests confirm this
(well, the log_32 bit just looks like constant time).

Is there any code in particular that uses sublist and is going slower than
you would expect?

As for `partition`, this implementation should pretty fast:

to-report partition [ lst l ]
  report n-values (length lst / l) [ sublist lst (? * l) (? * l + l) ]
end

Hope that helps!
Bryan

On Fri, Apr 1, 2016 at 10:05 AM Alan Isaac <[email protected]> wrote:

> Is `sublist` suprisingly slow?
>
> Related: might NetLogo consider adding a fast `partition` primitive,
> providing the basic functionality of Mathematica's `Partition`? (I.e.,
> given #lst and #n, return a list of sublists of length #n.)  It would
> alternatively be find to behave more like haskell's `chunkOf` (where the
> last chunk might  be shorter), but I think that's less intuitive.
>
> --
> You received this message because you are subscribed to the Google Groups
> "netlogo-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to