DEV Community

Josh Holbrook
Josh Holbrook

Posted on

1 1

Matanuska ADR 005 - Editor Operations

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 need to seek to the correct location within the array.

In general, binary search is going to be the most efficient mechanism for finding the right location, scaling at O(log n). However, in terms of actual use, lines are often being entered into the program in order - and in a new program, at the very end.

Decision

Line lookup for editing will follow this general algorithm:

  1. Check if the location is at or following the most recently modified line. In that case, return this location.
  2. Check if the location is at or following the last line. In that case, return this location.
  3. If these checks fail, find the location with a binary search.
  4. In all cases, save the location of the most recently inserted line.

Image of AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
πŸŽ₯ Audio/video file upload with real-time preview
πŸ—£οΈ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
πŸ“€ Export interview's subtitles in VTT format

Read full post

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay