Browse Source

Update 'README.md'

master
alistair 4 years ago
parent
commit
c400cdb1a9
  1. 26
      README.md

26
README.md

@ -12,3 +12,29 @@ Generates a random string of words of given length using UNIX words file. @@ -12,3 +12,29 @@ Generates a random string of words of given length using UNIX words file.
```
lipsum <num words>
```
## Explanation
It is a somewhat verbose C implementation of the following python function:
```python
import os
import random
def lipsum(num_words):
if os.path.exists('/usr/share/dict/words'):
file_name = '/usr/share/dict/words'
elif os.path.exists('/usr/dict/words'):
file_name = '/usr/dict/words'
else:
return 1
with open(file_name, 'r') as word_file:
words = word_file.readlines()
for i in range(num_words):
print(words[random.randint(0, len(words))], end=' ')
return 0
```

Loading…
Cancel
Save