Your question is Feature Module Implementation in NowInAndroid. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement a bookmark feature module for a Speechify-style app. The module must support adding a bookmark, removing a bookmark, checking whether a bookmark exists, and listing bookmarks in insertion order.
The key requirement is that the feature logic must be isolated from infrastructure concerns. Model the module with a clean interface and keep the core state and operations in pure Python.
Implement a function bookmark_module(operations) that processes a list of operations and returns the results for read operations.
Each operation is one of:
("add", id) adds bookmark id if it does not already exist.("remove", id) removes bookmark id if it exists.("exists", id) returns True if id is bookmarked, otherwise False.("list",) returns the current bookmarks in insertion order as a list.Bookmark ids are integers. Ignore duplicate adds and missing removes.
def bookmark_module(operations):