You are viewing a single comment's thread from:

RE: Building a fully Immutable Stack in C# - Includes SBD 0.001 puzzle buried in the article :)

in #programming7 years ago (edited)

That is the nature of immutability, yep, the push returns a new stack with 5 on the head of book, It forks the chain like a fork in blockchain, the 4 2 are common in updated along with the storage infrastructure. I mention this in the notes after that snippet but might not have been clear enough :)

The big mistake people not used to immutability might make is

book.push(5);

thinking book is updated. It has forked as has each call to push. Similar if you make an immutable ATV and change it the original tree is as is and a new copy is built with just the required tree rebuilt :)

If you look after a push/pop I always keep the new returned stack. I am a fan of functional but lisp has too many brackets for me :)

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 61038.67
ETH 2626.98
USDT 1.00
SBD 2.62