mapvar func doc iterate

This commit is contained in:
John Kerl 2016-12-10 12:37:37 -05:00
parent 9b03ad7427
commit dd62f0e982
7 changed files with 120 additions and 122 deletions

View file

@ -308,17 +308,17 @@ static function_lookup_t FUNCTION_LOOKUP_TABLE[] = {
"Convert argument to type of argument (e.g.\n"
"MT_STRING). For debug."},
{FUNC_CLASS_MAPS, "depth", 1,0, "xxx temp."},
{FUNC_CLASS_MAPS, "haskey", 2,0, "xxx temp."},
{FUNC_CLASS_MAPS, "joink", 2,0, "xxx temp."},
{FUNC_CLASS_MAPS, "joinkv", 3,0, "xxx temp."},
{FUNC_CLASS_MAPS, "joinv", 2,0, "xxx temp."},
{FUNC_CLASS_MAPS, "leafcount", 1,0, "xxx temp."},
{FUNC_CLASS_MAPS, "length", 1,0, "xxx temp."},
{FUNC_CLASS_MAPS, "mapdiff", 0,1, "xxx temp."},
{FUNC_CLASS_MAPS, "mapsum", 0,1, "xxx temp."},
{FUNC_CLASS_MAPS, "splitkv", 3,0, "xxx temp."},
{FUNC_CLASS_MAPS, "splitnv", 2,0, "xxx temp."},
{FUNC_CLASS_MAPS, "depth", 1,0, "Prints maximum depth of hashmap: ''. Scalars have depth 0."},
{FUNC_CLASS_MAPS, "haskey", 2,0, "True/false if map has/hasn't key, e.g. 'haskey($*, \"a\")' or 'haskey(mymap, mykey)'. Error if 1st argument is not a map."},
{FUNC_CLASS_MAPS, "joink", 2,0, "Makes string from map keys. E.g. 'joink($*, \",\")'."},
{FUNC_CLASS_MAPS, "joinkv", 3,0, "Makes string from map key-value pairs. E.g. 'joinkv(@v[2], \"=\", \",\")'"},
{FUNC_CLASS_MAPS, "joinv", 2,0, "Makes string from map keys. E.g. 'joinv(mymap, \",\")'."},
{FUNC_CLASS_MAPS, "leafcount", 1,0, "Counts total number of terminal values in hashmap. For single-level maps, same as length."},
{FUNC_CLASS_MAPS, "length", 1,0, "Counts number of top-level entries in hashmap. Scalars have length 1."},
{FUNC_CLASS_MAPS, "mapdiff", 0,1, "With 0 args, returns empty map. With 1 arg, returns copy of arg. With 2 or more, returns copy of arg 1 with all keys from any of remaining argument maps removed."},
{FUNC_CLASS_MAPS, "mapsum", 0,1, "With 0 args, returns empty map. With >= 1 arg, returns a map with key-value pairs from all arguments. Rightmost collisions win, e.g. 'mapsum({1:2,3,4},{1:5})' is '{1:5,3:4}'."},
{FUNC_CLASS_MAPS, "splitkv", 3,0, "Splits string by separators into map. E.g. 'splitkv(\"a=1,b=2,c=3\", \"=\", \",\")' gives '{\"a\" : 1, \"b\" : 2, \"c\" : 3}'."},
{FUNC_CLASS_MAPS, "splitnv", 2,0, "Splits string by separator into integer-indexed map. E.g. 'splitnv(\"a,b,c\" , \",\")' gives '{1 : \"a\", 2 : \"b\", 3 : \"c\"}'."},
{0, NULL, -1 , -1, NULL}, // table terminator
};

View file

@ -71,17 +71,17 @@ MAPVAR CHECKLIST:
* mv_error retvals vs. exitthrows vs. absentskips ... bleah
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
things which are always maps:
* maplit
* full srec
* full oosvar
things which can be maps:
* oosvar
* localvar
* func retval
* func args
* man mlr section on maps
o things which are always maps:
- maplit
- full srec
- full oosvar
o things which can be maps:
- oosvar
- localvar
- func retval
- func args
o what funcs are available
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mlr_dsl_cst_output_statements.c:
@ -252,8 +252,6 @@ UT FOR 5.0.0:
- ispresent isabsent ismap isscalar & all other predicates
- length depth leafcount
* [IO][PFS]S variables
================================================================
HYGIENE FOR 5.0.0:

View file

@ -605,33 +605,33 @@ $ mlr --ofmt '%.9lf' --opprint seqgen --start 1 --stop 28 then put '
' then put '$seconds=systime()' then step -a delta -f seconds then cut -x -f seconds
i o fcount seconds_delta
1 1 1 0
2 2 3 0.000036955
3 3 5 0.000014067
4 5 9 0.000016928
5 8 15 0.000023127
6 13 25 0.000031948
7 21 41 0.000051022
8 34 67 0.000075102
9 55 109 0.000117779
10 89 177 0.000183105
11 144 287 0.000277042
12 233 465 0.000441074
13 377 753 0.000703812
14 610 1219 0.001370192
15 987 1973 0.002070904
16 1597 3193 0.003092051
17 2584 5167 0.005866051
18 4181 8361 0.008458853
19 6765 13529 0.014276028
20 10946 21891 0.021137953
21 17711 35421 0.037570953
22 28657 57313 0.063245058
23 46368 92735 0.091686010
24 75025 150049 0.163563013
25 121393 242785 0.230818987
26 196418 392835 0.373414040
27 317811 635621 0.599045992
28 514229 1028457 0.981178045
2 2 3 0.000026941
3 3 5 0.000013113
4 5 9 0.000015974
5 8 15 0.000020981
6 13 25 0.000032902
7 21 41 0.000046015
8 34 67 0.000071049
9 55 109 0.000110865
10 89 177 0.000177145
11 144 287 0.000280857
12 233 465 0.000481129
13 377 753 0.000726938
14 610 1219 0.001166105
15 987 1973 0.001888037
16 1597 3193 0.003076792
17 2584 5167 0.007180214
18 4181 8361 0.009042978
19 6765 13529 0.012531996
20 10946 21891 0.020021915
21 17711 35421 0.039761066
22 28657 57313 0.057097912
23 46368 92735 0.089259148
24 75025 150049 0.147849798
25 121393 242785 0.231703997
26 196418 392835 0.374926090
27 317811 635621 0.696024895
28 514229 1028457 1.066029072
</pre>
</div>
<p/>
@ -663,33 +663,33 @@ $ mlr --ofmt '%.9lf' --opprint seqgen --start 1 --stop 28 then put '
' then put '$seconds=systime()' then step -a delta -f seconds then cut -x -f seconds
i o fcount seconds_delta
1 1 1 0
2 2 3 0.000038147
3 3 3 0.000015974
4 5 3 0.000011921
5 8 3 0.000010967
6 13 3 0.000011206
7 21 3 0.000010967
2 2 3 0.000030041
3 3 3 0.000013828
4 5 3 0.000013113
5 8 3 0.000011921
6 13 3 0.000010967
7 21 3 0.000012159
8 34 3 0.000010967
9 55 3 0.000010014
10 89 3 0.000010967
9 55 3 0.000010967
10 89 3 0.000011921
11 144 3 0.000010967
12 233 3 0.000014067
13 377 3 0.000010967
14 610 3 0.000010967
15 987 3 0.000010014
16 1597 3 0.000010014
12 233 3 0.000015020
13 377 3 0.000012159
14 610 3 0.000011921
15 987 3 0.000010967
16 1597 3 0.000010967
17 2584 3 0.000010967
18 4181 3 0.000010014
19 6765 3 0.000010014
20 10946 3 0.000010967
18 4181 3 0.000011206
19 6765 3 0.000010967
20 10946 3 0.000011921
21 17711 3 0.000010014
22 28657 3 0.000011921
23 46368 3 0.000012159
24 75025 3 0.000010967
25 121393 3 0.000010014
26 196418 3 0.000010967
27 317811 3 0.000010014
28 514229 3 0.000010014
22 28657 3 0.000014067
23 46368 3 0.000013828
24 75025 3 0.000011206
25 121393 3 0.000010967
26 196418 3 0.000011921
27 317811 3 0.000010967
28 514229 3 0.000010967
</pre>
</div>
<p/>

View file

@ -1622,37 +1622,37 @@ FUNCTIONS FOR FILTER/PUT
MT_STRING). For debug.
depth
(class=maps #args=1): xxx temp.
(class=maps #args=1): Prints maximum depth of hashmap: ''. Scalars have depth 0.
haskey
(class=maps #args=2): xxx temp.
(class=maps #args=2): True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)'. Error if 1st argument is not a map.
joink
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joink($*, ",")'.
joinkv
(class=maps #args=3): xxx temp.
(class=maps #args=3): Makes string from map key-value pairs. E.g. 'joinkv(@v[2], "=", ",")'
joinv
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joinv(mymap, ",")'.
leafcount
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts total number of terminal values in hashmap. For single-level maps, same as length.
length
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts number of top-level entries in hashmap. Scalars have length 1.
mapdiff
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With 1 arg, returns copy of arg. With 2 or more, returns copy of arg 1 with all keys from any of remaining argument maps removed.
mapsum
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With &gt;= 1 arg, returns a map with key-value pairs from all arguments. Rightmost collisions win, e.g. 'mapsum({1:2,3,4},{1:5})' is '{1:5,3:4}'.
splitkv
(class=maps #args=3): xxx temp.
(class=maps #args=3): Splits string by separators into map. E.g. 'splitkv("a=1,b=2,c=3", "=", ",")' gives '{"a" : 1, "b" : 2, "c" : 3}'.
splitnv
(class=maps #args=2): xxx temp.
(class=maps #args=2): Splits string by separator into integer-indexed map. E.g. 'splitnv("a,b,c" , ",")' gives '{1 : "a", 2 : "b", 3 : "c"}'.
KEYWORDS FOR PUT AND FILTER
all
@ -1956,7 +1956,7 @@ SEE ALSO
2016-12-09 MILLER(1)
2016-12-10 MILLER(1)
</pre>
</div>
<p/>

View file

@ -1475,37 +1475,37 @@ FUNCTIONS FOR FILTER/PUT
MT_STRING). For debug.
depth
(class=maps #args=1): xxx temp.
(class=maps #args=1): Prints maximum depth of hashmap: ''. Scalars have depth 0.
haskey
(class=maps #args=2): xxx temp.
(class=maps #args=2): True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)'. Error if 1st argument is not a map.
joink
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joink($*, ",")'.
joinkv
(class=maps #args=3): xxx temp.
(class=maps #args=3): Makes string from map key-value pairs. E.g. 'joinkv(@v[2], "=", ",")'
joinv
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joinv(mymap, ",")'.
leafcount
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts total number of terminal values in hashmap. For single-level maps, same as length.
length
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts number of top-level entries in hashmap. Scalars have length 1.
mapdiff
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With 1 arg, returns copy of arg. With 2 or more, returns copy of arg 1 with all keys from any of remaining argument maps removed.
mapsum
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With >= 1 arg, returns a map with key-value pairs from all arguments. Rightmost collisions win, e.g. 'mapsum({1:2,3,4},{1:5})' is '{1:5,3:4}'.
splitkv
(class=maps #args=3): xxx temp.
(class=maps #args=3): Splits string by separators into map. E.g. 'splitkv("a=1,b=2,c=3", "=", ",")' gives '{"a" : 1, "b" : 2, "c" : 3}'.
splitnv
(class=maps #args=2): xxx temp.
(class=maps #args=2): Splits string by separator into integer-indexed map. E.g. 'splitnv("a,b,c" , ",")' gives '{1 : "a", 2 : "b", 3 : "c"}'.
KEYWORDS FOR PUT AND FILTER
all
@ -1809,4 +1809,4 @@ SEE ALSO
2016-12-09 MILLER(1)
2016-12-10 MILLER(1)

View file

@ -2,12 +2,12 @@
.\" Title: mlr
.\" Author: [see the "AUTHOR" section]
.\" Generator: ./mkman.rb
.\" Date: 2016-12-09
.\" Date: 2016-12-10
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "MILLER" "1" "2016-12-09" "\ \&" "\ \&"
.TH "MILLER" "1" "2016-12-10" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Portability definitions
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2554,7 +2554,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=1): xxx temp.
(class=maps #args=1): Prints maximum depth of hashmap: ''. Scalars have depth 0.
.fi
.if n \{\
.RE
@ -2563,7 +2563,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=2): xxx temp.
(class=maps #args=2): True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)'. Error if 1st argument is not a map.
.fi
.if n \{\
.RE
@ -2572,7 +2572,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joink($*, ",")'.
.fi
.if n \{\
.RE
@ -2581,7 +2581,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=3): xxx temp.
(class=maps #args=3): Makes string from map key-value pairs. E.g. 'joinkv(@v[2], "=", ",")'
.fi
.if n \{\
.RE
@ -2590,7 +2590,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=2): xxx temp.
(class=maps #args=2): Makes string from map keys. E.g. 'joinv(mymap, ",")'.
.fi
.if n \{\
.RE
@ -2599,7 +2599,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts total number of terminal values in hashmap. For single-level maps, same as length.
.fi
.if n \{\
.RE
@ -2608,7 +2608,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=1): xxx temp.
(class=maps #args=1): Counts number of top-level entries in hashmap. Scalars have length 1.
.fi
.if n \{\
.RE
@ -2617,7 +2617,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With 1 arg, returns copy of arg. With 2 or more, returns copy of arg 1 with all keys from any of remaining argument maps removed.
.fi
.if n \{\
.RE
@ -2626,7 +2626,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps variadic): xxx temp.
(class=maps variadic): With 0 args, returns empty map. With >= 1 arg, returns a map with key-value pairs from all arguments. Rightmost collisions win, e.g. 'mapsum({1:2,3,4},{1:5})' is '{1:5,3:4}'.
.fi
.if n \{\
.RE
@ -2635,7 +2635,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=3): xxx temp.
(class=maps #args=3): Splits string by separators into map. E.g. 'splitkv("a=1,b=2,c=3", "=", ",")' gives '{"a" : 1, "b" : 2, "c" : 3}'.
.fi
.if n \{\
.RE
@ -2644,7 +2644,7 @@ MT_STRING). For debug.
.RS 0
.\}
.nf
(class=maps #args=2): xxx temp.
(class=maps #args=2): Splits string by separator into integer-indexed map. E.g. 'splitnv("a,b,c" , ",")' gives '{1 : "a", 2 : "b", 3 : "c"}'.
.fi
.if n \{\
.RE

View file

@ -6608,27 +6608,27 @@ string (class=conversion #args=1): Convert int/float/bool/string to string.
typeof (class=conversion #args=1): Convert argument to type of argument (e.g.
MT_STRING). For debug.
depth (class=maps #args=1): xxx temp.
depth (class=maps #args=1): Prints maximum depth of hashmap: ''. Scalars have depth 0.
haskey (class=maps #args=2): xxx temp.
haskey (class=maps #args=2): True/false if map has/hasn't key, e.g. 'haskey($*, "a")' or 'haskey(mymap, mykey)'. Error if 1st argument is not a map.
joink (class=maps #args=2): xxx temp.
joink (class=maps #args=2): Makes string from map keys. E.g. 'joink($*, ",")'.
joinkv (class=maps #args=3): xxx temp.
joinkv (class=maps #args=3): Makes string from map key-value pairs. E.g. 'joinkv(@v[2], "=", ",")'
joinv (class=maps #args=2): xxx temp.
joinv (class=maps #args=2): Makes string from map keys. E.g. 'joinv(mymap, ",")'.
leafcount (class=maps #args=1): xxx temp.
leafcount (class=maps #args=1): Counts total number of terminal values in hashmap. For single-level maps, same as length.
length (class=maps #args=1): xxx temp.
length (class=maps #args=1): Counts number of top-level entries in hashmap. Scalars have length 1.
mapdiff (class=maps variadic): xxx temp.
mapdiff (class=maps variadic): With 0 args, returns empty map. With 1 arg, returns copy of arg. With 2 or more, returns copy of arg 1 with all keys from any of remaining argument maps removed.
mapsum (class=maps variadic): xxx temp.
mapsum (class=maps variadic): With 0 args, returns empty map. With &gt;= 1 arg, returns a map with key-value pairs from all arguments. Rightmost collisions win, e.g. 'mapsum({1:2,3,4},{1:5})' is '{1:5,3:4}'.
splitkv (class=maps #args=3): xxx temp.
splitkv (class=maps #args=3): Splits string by separators into map. E.g. 'splitkv("a=1,b=2,c=3", "=", ",")' gives '{"a" : 1, "b" : 2, "c" : 3}'.
splitnv (class=maps #args=2): xxx temp.
splitnv (class=maps #args=2): Splits string by separator into integer-indexed map. E.g. 'splitnv("a,b,c" , ",")' gives '{1 : "a", 2 : "b", 3 : "c"}'.
To set the seed for urand, you may specify decimal or hexadecimal 32-bit
numbers of the form "mlr --seed 123456789" or "mlr --seed 0xcafefeed".