From fccf6763ce90ce12536fd4b6a702c8d0afe876df Mon Sep 17 00:00:00 2001 From: Attila Magyar Date: Sun, 20 Jun 2021 00:04:35 +0200 Subject: [PATCH] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 6554546..883a252 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ The quotation code is compiled into the enclosing word and bypassed by a jump. A ## List +A list is a dynamic, ordered data structed. `` \ creates a new empty list @@ -201,9 +202,12 @@ The quotation code is compiled into the enclosing word and bypassed by a jump. A `[ 1 2 3 ]` \ creates a list with 3 elements. +Lists are java.util.ArrayList instances and garbage collected automatically by the host language. ## Maps +Maps contain key value pairs. + `` \ creates a new empty map @@ -211,5 +215,24 @@ The quotation code is compiled into the enclosing word and bypassed by a jump. A `#[ 'key1' 'value1' ]#` \ same as above +Lists are java.util.LinkedHashMap instances and garbage collected automatically by the host language. + +## Collection operations + +```forth +[ 1 2 3 4 ] { . } each \ iterets through the list and calls the quotation on each element +``` + +```forth +[ 1 2 3 4 ] { odd? } filter \ selects only the odd items from the list [ 1 3 ] +``` + +```forth +[ 1 2 3 4 ] { dup * } map \ transforms the list to a new list that contain the squares of the original items [ 1 4 9 16 ] +``` + +```forth +1 5 upto \ creates a list like [ 1 2 3 4 ] +``` ## HTTP