29
Dec
This article is a repost of an ADR from Matanuska BASIC, my attempt to write a BASIC interpreter in TypeScript. Context The editor needs to insert, update and delete lines from a Program. These lines are ordered in an array. Inserting into arrays is not particularly efficient as compared to a hash map. One way to handle this may be to store indexes line numbers in a Map - that would give O(1) access to the location of a line. However, that lookup won't work if the line doesn't exist yet, and requires an additional data structure. Therefore, we will…