Search a list
Output:
Or, including the "extra credit" task:
Output:
The built-in method .first
takes a smart-matcher, and returns the first matching list element.
The :k
adverb tells it to return the key (a.k.a. list index) instead of the value of the matching element.
The :end
adverb tells it to start searching from the end of the list.
If you plan to do many searches on the same large list, you might want to build a search hash first for efficient look-up:
Last updated