Created
June 17, 2011 22:56
-
-
Save hunner/1032544 to your computer and use it in GitHub Desktop.
This is an example of procedural languages at work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## | |
## Procedural languages: | |
## | |
a = [] | |
w=File.readlines('/usr/share/dict/words') | |
r=(0..10);c=r.map{Hash.new(0)};r.each{|i| | |
w.each{|v|c[i][v[i,3]]+=1 if v.length>i&& | |
v !~/'|(in|ing|ion|er?s?|eds|ard|or?)$/}} | |
10.times{s=w[rand(w.length)][0,2];r.each{ | |
|i| s=s+(c[i].sort_by{|x|-x[-1]+rand(100) | |
}.find{|x|x[0]=~/^#{s[-2,2]}/}||"\n\n\n"). | |
first[-1,1]};eval(97.chr)<<s.strip if !w. | |
include?(s.strip+"\n")||(s.strip.size<4)} | |
puts a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment