Skip to content

Commit e8ae302

Browse files
committed
updating readme with more examples
1 parent 9f21280 commit e8ae302

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ A fluent-interface and iterators for chaining algorithms over slices.
44

55
# Examples
66

7+
Concatenate, trim, and title string:
8+
```Zig
9+
const result = Fluent.init(str_a) // initialize our interface on str_a
10+
.concat(str_b, buf[0..]) // concatenate str_b into buffer
11+
.trim(.periphery, .scalar, ' ') // trim spaces on both sides
12+
.title(); // python title function
13+
```
14+
15+
Fuse map-functions to calculate sigmoid to buffer:
16+
```
17+
const x = Fluent.init(buf[0..])
18+
.copy(&[_]f32{ -2, -1, 0, 1, 2 })
19+
.map(.{
20+
Fluent.negate,
21+
std.math.exp,
22+
Fluent.bind(.{ 1.0 }, Fluent.add),
23+
Fluent.bind(.{ 1.0 }, Fluent.div),
24+
});
25+
```
26+
727
Copy the reverse of a list using a reverse iterator:
828
```Zig
929
const count = Fluent.iterator(.reverse, items_a[0..]).write(items_b[0..]);

0 commit comments

Comments
 (0)