-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathArrayToHash.calc
49 lines (45 loc) · 1.08 KB
/
ArrayToHash.calc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Let ( [
rowCount = PatternCount ( array ; rowDelimiter ) ;
row =
TextBetween (
rowDelimiter & array & rowDelimiter ;
rowDelimiter ;
rowDelimiter ;
1
) ;
row =
If (
Left ( row ; 1 ) = columnDelimiter ; row ;
columnDelimiter & row & columnDelimiter
) ;
name = TextBetween ( row ; columnDelimiter ; columnDelimiter ; nameColumn ) ;
value = TextBetween ( row ; columnDelimiter ; columnDelimiter ; valueColumn )
] ;
# ( name ; value )
& If (
rowCount > 1 ;
¶ & ArrayToHash (
TextBetween ( array ; rowDelimiter ; "" ; 1 ) ;
rowDelimiter ;
columnDelimiter ;
nameColumn ;
valueColumn
)
)
)
/* —————————————————————————————— //
NAME:
ArrayToHash ( array ; rowDelimiter ; columnDelimiter ; nameColumn ; valueColumn )
PURPOSE:
Generates list of name-value pairs using columns in tabular array
EXAMPLES:
ArrayToHash (
"dog|woof|chow¶cat|meow|kibble" ;
"¶"
"|" ;
1 ;
3
) = "<:dog:=chow:>¶<:cat:=kibble:>"
HISTORY:
Created: 2011-Nov-10 10h26 PST — Donovan A. Chandler
*/