Reputation: 87
I have used some tcl code in a design tool to get the list of standard cells in a single list. Tcl has a limitation of processing a large number of elements to read from any list. How do I split these list of standard cells in a single data structure for the tool to read?
Upvotes: 0
Views: 360
Reputation: 137567
If you've got a big list that you've got to split into small chunks for processing and don't want to just do all the pieces one by one with foreach
, you can do this:
set big_list {lots and lots and lots...}
set index 0
set stride 10
while true {
set chunk [lrange $big_list $index [expr {$index + $stride - 1}]]
# Nothing left; got to the end
if {![llength $chunk]} break
incr index $stride
process_chunk $chunk
}
Tune the stride size for how much you can feed through. (Theoretically, you can do auto-tuning of the stride length if there's some complex limit involved. Practically, just pick something by hand that works and isn't too inefficient; auto-tuning algorithms are always quite a lot more complicated.)
Upvotes: 1