From 42ec7286b2d36a9ba22925f816a17cb1cc2aa5ce Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Oct 2021 11:32:16 +0800 Subject: + Penlight --- .../Penlight/docs/libraries/pl.comprehension.html | 165 +++++++++++++++++++++ 1 file changed, 165 insertions(+) create mode 100644 Data/Libraries/Penlight/docs/libraries/pl.comprehension.html (limited to 'Data/Libraries/Penlight/docs/libraries/pl.comprehension.html') diff --git a/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html b/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html new file mode 100644 index 0000000..4c31b64 --- /dev/null +++ b/Data/Libraries/Penlight/docs/libraries/pl.comprehension.html @@ -0,0 +1,165 @@ + + + + + Penlight Documentation + + + + +
+ +
+ +
+
+
+ + +
+ + + + + + +
+ +

Module pl.comprehension

+

List comprehensions implemented in Lua.

+

See the wiki page

+ + +
+local C= require 'pl.comprehension' . new()
+
+C ('x for x=1,10') ()
+==> {1,2,3,4,5,6,7,8,9,10}
+C 'x^2 for x=1,4' ()
+==> {1,4,9,16}
+C '{x,x^2} for x=1,4' ()
+==> {{1,1},{2,4},{3,9},{4,16}}
+C '2*x for x' {1,2,3}
+==> {2,4,6}
+dbl = C '2*x for x'
+dbl {10,20,30}
+==> {20,40,60}
+C 'x for x if x % 2 == 0' {1,2,3,4,5}
+==> {2,4}
+C '{x,y} for x = 1,2 for y = 1,2' ()
+==> {{1,1},{1,2},{2,1},{2,2}}
+C '{x,y} for x for y' ({1,2},{10,20})
+==> {{1,10},{1,20},{2,10},{2,20}}
+assert(C 'sum(x^2 for x)' {2,3,4} == 2^2+3^2+4^2)
+
+ +

(c) 2008 David Manura. Licensed under the same terms as Lua (MIT license).

+ +

Dependencies: pl.utils, pl.luabalanced

+ +

See the Guide

+ + + +
+
+ + + + +
+
+
+generated by LDoc 1.4.6 +
+
+ + -- cgit v1.1-26-g67d0