Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are there any advantages to using lists verses blocks?

advantages blocks lists verses
0
10 Posted

Are there any advantages to using lists verses blocks?

0

The advantages become more obvious with large lists when doing inserts or removes. On a large block, all the data gets shuffled doing an insert at the head. On a list, existing data is never moved. This means that lists take more space than blocks as there is a linked list associated with the data. However, the speed advantages are significant. Here’s an example: >> blk: make block! 20000 == [] >> t: now/time loop 20000 [ insert head blk 1 ] now/time – t == 0:00:35 >> lst: make list! 20000 == make list! [] >> t: now/time loop 20000 [ insert head lst 1 ] now/time – t == 0:00 NOTE: The time for BLK is not linear with the number of iterations because the amount of data that must be moved with each insert becomes larger and larger.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123