Skip to content

Commit 6fbf842

Browse files
committed
Sync: Rebuild Readme
1 parent 8fa9078 commit 6fbf842

4 files changed

Lines changed: 421 additions & 5 deletions

File tree

source/List/List.SelectBySuffix.pq

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
let
2+
// expects a list of pairs of 2 elements, first is the digit, 2nd is the unit
3+
4+
List.SelectBySuffix.Func = ( items as list, unit as text ) as any =>
5+
List.First(
6+
List.Select( items,
7+
(i) => i{1} = unit ), null ){0}?,
8+
9+
List.SelectBySuffix.Type = type function (
10+
items as (type { text }),
11+
unit as text
12+
) as text meta [
13+
Documentation.Name = "List.SelectBySuffix",
14+
Documentation.LongDescription = Text.Combine({
15+
"After calling <code>Splitter.SplitDigitWithSuffix()</code>, this function will choose one item from the pair", "", "#(tab)<b>Example</b>: For the text <code>'2m 3s'</code> find <code>'2'<code> if unit is <code>'m'<code>"
16+
}, "<br>"),
17+
Documentation.Examples = {
18+
[
19+
Description = "Selects the first item in a list that ends with the specified suffix",
20+
Code = Format.DocExpand( "List.SelectBySuffix( { {␞2␞, ␞d␞}, {␞3␞, ␞h␞} }, ␞h␞)" ),
21+
Result = Format.DocExpand("3")
22+
],
23+
[
24+
Description = "Selects the first item in a list that ends with the specified suffix",
25+
Code = Format.DocExpand( "List.SelectBySuffix( { {␞2␞, ␞d␞}, {␞3␞, ␞h␞} }, ␞d␞)" ),
26+
Result = Format.DocExpand("2")
27+
]
28+
}
29+
]
30+
in
31+
Value.ReplaceType( List.SelectBySuffix.Func, List.SelectBySuffix.Type )
32+

0 commit comments

Comments
 (0)