Post Reply 
Free42: Unlimited-length strings and other type extensions
02-23-2021, 08:23 PM
Post: #39
RE: Free42: Unlimited-length strings and other type extensions
The little LISPer in me says you can't have lists without map & zip! Wink

The map function takes a single parameter function & a list/string/matrix. It applies the function to every element. It returns a new list/string/matrix of the function results.

map(abs, {1 -2 3}) => {1 2 3}

zip takes a two parameter function and two lists/strings/matrices. It applies the function to the first element of each container, then the second, etc... It returns one list/string/matrix containing the function results.

zip(+, {1,2,3}, {1,2,1}) => {2, 4, 4}

A GETELT would be nice -- i.e. get element of the list/string/matrix. For lists & strings it would take an integer. For a matrix it could take a list like the 28s did, or you could use one (the Nth item in the array) or two (row & column) integers on the stack. This is not ambiguous. If Y has an integer, then we assume Z is a matrix. If Y is not an integer, then we assume it is the collection from which we extract our element.

It would be also be cool if NEWLIST took an integer argument which tells it to make the list from the bottom N stack elements. With an unlimited stack this kind of functionality is more natural.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Free42: Unlimited-length strings and other type extensions - richmit - 02-23-2021 08:23 PM



User(s) browsing this thread: 1 Guest(s)