Commit 88cf37d6 authored by Camil Staps's avatar Camil Staps 🚀

Merge branch 'local-def-in-zf' into 'master'

Add notion of local definitons in ZF

See merge request !220
parents ecd561ca 7a5deb59
Pipeline #18151 passed with stages
in 19 minutes and 36 seconds
......@@ -849,21 +849,26 @@ bs_with =
bs_zf =
{ syntax_title = "list comprehension"
, syntax_patterns = map exact ["ZF-expression", "ZF", "zf", "*comprehension", "<-", "<\\|-", "<-:", "\\\\\\\\", ",", "&", "\\|"]
, syntax_patterns = map exact ["ZF-expression", "ZF", "zf", "*comprehension", "<-", "<\\|-", "<-:", "\\\\\\\\", ",", "&", "\\|", "let"]
, syntax_code =
[ "[... \\\\ ... <- ...]"
, "{... \\\\ ... <- ...}"
]
, syntax_description = "Constructs a list or array composed of elements drawn from other lists or arrays."
, syntax_description = "Constructs a list or array composed of elements drawn from other lists or arrays. It is possible to use local definitions as well (see {{`let`}})."
, syntax_doc_locations = [CLR 6 "4.2.1" "_Toc311798024", CLR 6 "4.4.1" "_Toc311798032"]
, syntax_examples = map (add_imports ["StdEnv", "StdMaybe"] o EXs "macro")
[ "cartesian = [(x,y) \\\\ x <- [1,2,3], y <- [10,20]] // Cartesian product: (1,10), (1,20), (2,10), (2,20), (3,10), (3,20)"
, "zip xs ys = [(x,y) \\\\ x <- xs & y <- ys] // Pairwise zip through the lists"
, "filter f xs = [x \\\\ x <- xs | f x] // Guard to add conditions"
, "catMaybes ms = [x \\\\ Just x <- ms] // Pattern matching in the selector"
, "zip xs ys = [(x,y) \\\\ x <- xs & y <- ys] // Pairwise zip through the lists"
, "filter f xs = [x \\\\ x <- xs | f x] // Guard to add conditions"
, "catMaybes ms = [x \\\\ Just x <- ms] // Pattern matching in the selector"
, "triangle = [(x,y) \\\\ x <- [1,2,3], y <- [1..x]] // Reusing x in the next generator: (1,1), (2,1), (2,2), (3,1), (3,2), (3,3)"
, "arrToList a = [x \\\\ x <-: a] // <-: to draw elements from an array"
, "listToArr l = {x \\\\ x <- l} // {..} to create an array"
, "castList xs = [|x \\\\ x <|- xs] // The two pipe characters make both xs and the result overloaded lists"
, "arrToList a = [x \\\\ x <-: a] // <-: to draw elements from an array"
, "listToArr l = {x \\\\ x <- l} // {..} to create an array"
, "castList xs = [|x \\\\ x <|- xs] // The two pipe characters make both xs and the result overloaded lists"
] ++
[ add_imports ["StdEnv"] $ EXs "rhs" $
"[ sx \\\\ x <- [0..]\n" +
"\t, let sx = toString x // The let must end with a newline\n" +
"\t]"
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment