Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
EntilZha committed Mar 12, 2015
1 parent 943769f commit aa4b08c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ reduce(q, map(g, filter(f, l)))
# Python list comprehension
reduce(q, [g(x) for x in l if f(x)])

# ScalaFunction style
# ScalaFunctional style
from functional import seq
seq(l).filter(f).map(g).reduce(q)

# ScalaFunctional word count
l = seq("the why the what of word counting of english".split(" "))
l.map(lambda word: (word, 1)).reduce_by_key(lambda x, y: x + y)
# [('what', 1), ('word', 1), ('of', 2), ('english', 1), ('the', 2), ('counting', 1), ('why', 1)]
```

# Inspiration
Expand Down Expand Up @@ -55,12 +60,6 @@ seq([1, 2, 3])[0]
seq([1, 2, 3])[-1]
# -> 3
```
## Word count in one line
```python
l = seq("the why the what of word counting of english".split(" "))
l.map(lambda word: (word, 1)).reduce_by_key(lambda x, y: x + y)
# -> [('what', 1), ('word', 1), ('of', 2), ('english', 1), ('the', 2), ('counting', 1), ('why', 1)]
```

## List of supported functions
### List to List
Expand Down

0 comments on commit aa4b08c

Please sign in to comment.