Skip to content

Commit 5021a28

Browse files
committed
#27 Improve README (examples & installation)
1 parent 6a44cd7 commit 5021a28

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,68 @@ The main point is not to add one-liners features to COS. The main point is to br
2323
Loop is just an instrument to solve the problem. In common, the problem is to traverse by collection and do some action with every element. Do you really need a loop for it? No. You choose a loop because COS supports loops only. DeclarativeCOS allows to write the code in declarative style. Just declare what you want to do and DeclarativeCOS will do all the rest for you.
2424
<br/>
2525
<br/>
26+
# OK. Examples, please.
27+
28+
**What is about output collection?**
29+
```
30+
/// Usual way
31+
32+
set i = collection.Next("")
33+
34+
while (i '= "") {
35+
set item = collection.GetAt(i)
36+
37+
w item,!
38+
39+
set i = collection.Next(i)
40+
}
41+
```
42+
```
43+
/// New way
44+
45+
d ##class(DeclarativeCOS.Binder).%New(collection, "io:println").ForEach()
46+
47+
/// or
48+
49+
zforeach $zbind(collection, "io:println")
50+
```
51+
52+
**What is about output collection? (one more)**
53+
```
54+
/// Usual way
55+
56+
set i = collection.Next("")
57+
58+
while (i '= "") {
59+
set item = collection.GetAt(i)
60+
61+
w item _ " "
62+
63+
set i = collection.Next(i)
64+
}
65+
```
66+
```
67+
/// New way
68+
69+
w ##class(DeclarativeCOS.Joiner).%New(collection, " ").join()
70+
71+
/// or
72+
73+
w $zjoin(collection, " ")
74+
```
75+
<br/>
76+
<br/>
77+
# How to install it?
78+
79+
In the root of the repo you can find two xml files:
80+
**install.base.xml**,
81+
**install.advanced.xml**.
82+
83+
The first file installs all needed classes to perform any examples above.
84+
85+
The second file installs short functions and commands: zforeach, $zmap, $zfind, $zfilter, $zexists, $zcount, $zjoin.
86+
<br/>
87+
<br/>
2688
# OK. How does it work?
2789

2890
**5 steps:**

0 commit comments

Comments
 (0)