diff options
Diffstat (limited to 'tests/lexers/rb/example5.txt')
| -rw-r--r-- | tests/lexers/rb/example5.txt | 10683 |
1 files changed, 10683 insertions, 0 deletions
diff --git a/tests/lexers/rb/example5.txt b/tests/lexers/rb/example5.txt new file mode 100644 index 00000000..5edc3d94 --- /dev/null +++ b/tests/lexers/rb/example5.txt @@ -0,0 +1,10683 @@ +---input--- +# -*- ruby -*- + +# Local variables: +# indent-tabs-mode: nil +# ruby-indent-level: 4 +# End: + +# @@PLEAC@@_NAME +# @@SKIP@@ Ruby + +# @@PLEAC@@_WEB +# @@SKIP@@ http://www.ruby-lang.org + + +# @@PLEAC@@_1.0 +string = '\n' # two characters, \ and an n +string = 'Jon \'Maddog\' Orwant' # literal single quotes + +string = "\n" # a "newline" character +string = "Jon \"Maddog\" Orwant" # literal double quotes + +string = %q/Jon 'Maddog' Orwant/ # literal single quotes + +string = %q[Jon 'Maddog' Orwant] # literal single quotes +string = %q{Jon 'Maddog' Orwant} # literal single quotes +string = %q(Jon 'Maddog' Orwant) # literal single quotes +string = %q<Jon 'Maddog' Orwant> # literal single quotes + +a = <<"EOF" +This is a multiline here document +terminated by EOF on a line by itself +EOF + + +# @@PLEAC@@_1.1 +value = string[offset,count] +value = string[offset..-1] + +string[offset,count] = newstring +string[offset..-1] = newtail + +# in Ruby we can also specify intervals by their two offsets +value = string[offset..offs2] +string[offset..offs2] = newstring + +leading, s1, s2, trailing = data.unpack("A5 x3 A8 A8 A*") + +fivers = string.unpack("A5" * (string.length/5)) + +chars = string.unpack("A1" * string.length) + +string = "This is what you have" +# +012345678901234567890 Indexing forwards (left to right) +# 109876543210987654321- Indexing backwards (right to left) +# note that 0 means 10 or 20, etc. above + +first = string[0, 1] # "T" +start = string[5, 2] # "is" +rest = string[13..-1] # "you have" +last = string[-1, 1] # "e" +end_ = string[-4..-1] # "have" +piece = string[-8, 3] # "you" + +string[5, 2] = "wasn't" # change "is" to "wasn't" +string[-12..-1] = "ondrous" # "This wasn't wondrous" +string[0, 1] = "" # delete first character +string[-10..-1] = "" # delete last 10 characters + +if string[-10..-1] =~ /pattern/ + puts "Pattern matches in last 10 characters" +end + +string[0, 5].gsub!(/is/, 'at') + +a = "make a hat" +a[0, 1], a[-1, 1] = a[-1, 1], a[0, 1] + +a = "To be or not to be" +b = a.unpack("x6 A6") + +b, c = a.unpack("x6 A2 X5 A2") +puts "#{b}\n#{c}\n" + +def cut2fmt(*args) + template = '' + lastpos = 1 + for place in args + template += "A" + (place - lastpos).to_s + " " + lastpos = place + end + template += "A*" + return template +end + +fmt = cut2fmt(8, 14, 20, 26, 30) + + +# @@PLEAC@@_1.2 +# careful! "b is true" doesn't mean "b != 0" (0 is true in Ruby) +# thus no problem of "defined" later since only nil is false +# the following sets to `c' if `b' is nil or false +a = b || c + +# if you need Perl's behaviour (setting to `c' if `b' is 0) the most +# effective way is to use Numeric#nonzero? (thanks to Dave Thomas!) +a = b.nonzero? || c + +# you will still want to use defined? in order to test +# for scope existence of a given object +a = defined?(b) ? b : c + +dir = ARGV.shift || "/tmp" + + +# @@PLEAC@@_1.3 +v1, v2 = v2, v1 + +alpha, beta, production = %w(January March August) +alpha, beta, production = beta, production, alpha + + +# @@PLEAC@@_1.4 +num = char[0] +char = num.chr + +# Ruby also supports having a char from character constant +num = ?r + +char = sprintf("%c", num) +printf("Number %d is character %c\n", num, num) + +ascii = string.unpack("C*") +string = ascii.pack("C*") + +hal = "HAL" +ascii = hal.unpack("C*") +# We can't use Array#each since we can't mutate a Fixnum +ascii.collect! { |i| + i + 1 # add one to each ASCII value +} +ibm = ascii.pack("C*") +puts ibm + + +# @@PLEAC@@_1.5 +array = string.split('') + +array = string.unpack("C*") + +string.scan(/./) { |b| + # do something with b +} + +string = "an apple a day" +print "unique chars are: ", string.split('').uniq.sort, "\n" + +sum = 0 +for ascval in string.unpack("C*") # or use Array#each for a pure OO style :) + sum += ascval +end +puts "sum is #{sum & 0xffffffff}" # since Ruby will go Bignum if necessary + +# @@INCLUDE@@ include/ruby/slowcat.rb + + +# @@PLEAC@@_1.6 +revbytes = string.reverse + +revwords = string.split(" ").reverse.join(" ") + +revwords = string.split(/(\s+)/).reverse.join + +# using the fact that IO is Enumerable, you can directly "select" it +long_palindromes = File.open("/usr/share/dict/words"). + select { |w| w.chomp!; w.reverse == w && w.length > 5 } + + +# @@PLEAC@@_1.7 +while string.sub!("\t+") { ' ' * ($&.length * 8 - $`.length % 8) } +end + + +# @@PLEAC@@_1.8 +'You owe #{debt} to me'.gsub(/\#{(\w+)}/) { eval($1) } + +rows, cols = 24, 80 +text = %q(I am #{rows} high and #{cols} long) +text.gsub!(/\#{(\w+)}/) { eval("#{$1}") } +puts text + +'I am 17 years old'.gsub(/\d+/) { 2 * $&.to_i } + + +# @@PLEAC@@_1.9 +e = "bo peep".upcase +e.downcase! +e.capitalize! + +"thIS is a loNG liNE".gsub!(/\w+/) { $&.capitalize } + + +# @@PLEAC@@_1.10 +"I have #{n+1} guanacos." +print "I have ", n+1, " guanacos." + + +# @@PLEAC@@_1.11 +var = <<'EOF'.gsub(/^\s+/, '') + your text + goes here +EOF + + +# @@PLEAC@@_1.12 +string = "Folding and splicing is the work of an editor,\n"+ + "not a mere collection of silicon\n"+ + "and\n"+ + "mobile electrons!" + +def wrap(str, max_size) + all = [] + line = '' + for l in str.split + if (line+l).length >= max_size + all.push(line) + line = '' + end + line += line == '' ? l : ' ' + l + end + all.push(line).join("\n") +end + +print wrap(string, 20) +#=> Folding and +#=> splicing is the +#=> work of an editor, +#=> not a mere +#=> collection of +#=> silicon and mobile +#=> electrons! + + +# @@PLEAC@@_1.13 +string = %q(Mom said, "Don't do that.") +string.gsub(/['"]/) { '\\'+$& } +string.gsub(/['"]/, '\&\&') +string.gsub(/[^A-Z]/) { '\\'+$& } +"is a test!".gsub(/\W/) { '\\'+$& } # no function like quotemeta? + + +# @@PLEAC@@_1.14 +string.strip! + + +# @@PLEAC@@_1.15 +def parse_csv(text) + new = text.scan(/"([^\"\\]*(?:\\.[^\"\\]*)*)",?|([^,]+),?|,/) + new << nil if text[-1] == ?, + new.flatten.compact +end + +line = %q<XYZZY,"","O'Reilly, Inc","Wall, Larry","a \"glug\" bit,",5,"Error, Core Dumped"> +fields = parse_csv(line) +fields.each_with_index { |v,i| + print "#{i} : #{v}\n"; +} + + +# @@PLEAC@@_1.16 +# Use the soundex.rb Library from Michael Neumann. +# http://www.s-direktnet.de/homepages/neumann/rb_prgs/Soundex.rb +require 'Soundex' + +code = Text::Soundex.soundex(string) +codes = Text::Soundex.soundex(array) + +# substitution function for getpwent(): +# returns an array of user entries, +# each entry contains the username and the full name +def login_names + result = [] + File.open("/etc/passwd") { |file| + file.each_line { |line| + next if line.match(/^#/) + cols = line.split(":") + result.push([cols[0], cols[4]]) + } + } + result +end + +puts "Lookup user: " +user = STDIN.gets +user.chomp! +exit unless user +name_code = Text::Soundex.soundex(user) + +splitter = Regexp.new('(\w+)[^,]*\b(\w+)') +for username, fullname in login_names do + firstname, lastname = splitter.match(fullname)[1,2] + if name_code == Text::Soundex.soundex(username) + || name_code == Text::Soundex.soundex(firstname) + || name_code == Text::Soundex.soundex(lastname) + then + puts "#{username}: #{firstname} #{lastname}" + end +end + + +# @@PLEAC@@_1.17 +# @@INCLUDE@@ include/ruby/fixstyle.rb + + +# @@PLEAC@@_1.18 +# @@INCLUDE@@ include/ruby/psgrep.rb + + +# @@PLEAC@@_2.1 +# Matz tells that you can use Integer() for strict checked conversion. +Integer("abc") +#=> `Integer': invalid value for Integer: "abc" (ArgumentError) +Integer("567") +#=> 567 + +# You may use Float() for floating point stuff +Integer("56.7") +#=> `Integer': invalid value for Integer: "56.7" (ArgumentError) +Float("56.7") +#=> 56.7 + +# You may also use a regexp for that +if string =~ /^[+-]?\d+$/ + p 'is an integer' +else + p 'is not' +end + +if string =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/ + p 'is a decimal number' +else + p 'is not' +end + + +# @@PLEAC@@_2.2 +# equal(num1, num2, accuracy) : returns true if num1 and num2 are +# equal to accuracy number of decimal places +def equal(i, j, a) + sprintf("%.#{a}g", i) == sprintf("%.#{a}g", j) +end + +wage = 536 # $5.36/hour +week = 40 * wage # $214.40 +printf("One week's wage is: \$%.2f\n", week/100.0) + + +# @@PLEAC@@_2.3 +num.round # rounds to integer + +a = 0.255 +b = sprintf("%.2f", a) +print "Unrounded: #{a}\nRounded: #{b}\n" +printf "Unrounded: #{a}\nRounded: %.2f\n", a + +print "number\tint\tfloor\tceil\n" +a = [ 3.3 , 3.5 , 3.7, -3.3 ] +for n in a + printf("% .1f\t% .1f\t% .1f\t% .1f\n", # at least I don't fake my output :) + n, n.to_i, n.floor, n.ceil) +end + + +# @@PLEAC@@_2.4 +def dec2bin(n) + [n].pack("N").unpack("B32")[0].sub(/^0+(?=\d)/, '') +end + +def bin2dec(n) + [("0"*32+n.to_s)[-32..-1]].pack("B32").unpack("N")[0] +end + + +# @@PLEAC@@_2.5 +for i in x .. y + # i is set to every integer from x to y, inclusive +end + +x.step(y,7) { |i| + # i is set to every integer from x to y, stepsize = 7 +} + +print "Infancy is: " +(0..2).each { |i| + print i, " " +} +print "\n" + + +# @@PLEAC@@_2.6 +# We can add conversion methods to the Integer class, +# this makes a roman number just a representation for normal numbers. +class Integer + + @@romanlist = [["M", 1000], + ["CM", 900], + ["D", 500], + ["CD", 400], + ["C", 100], + ["XC", 90], + ["L", 50], + ["XL", 40], + ["X", 10], + ["IX", 9], + ["V", 5], + ["IV", 4], + ["I", 1]] + + def to_roman + remains = self + roman = "" + for sym, num in @@romanlist + while remains >= num + remains -= num + roman << sym + end + end + roman + end + + def Integer.from_roman(roman) + ustr = roman.upcase + sum = 0 + for entry in @@romanlist + sym, num = entry[0], entry[1] + while sym == ustr[0, sym.length] + sum += num + ustr.slice!(0, sym.length) + end + end + sum + end + +end + + +roman_fifteen = 15.to_roman +puts "Roman for fifteen is #{roman_fifteen}" +i = Integer.from_roman(roman_fifteen) +puts "Converted back, #{roman_fifteen} is #{i}" + +# check +for i in (1..3900) + r = i.to_roman + j = Integer.from_roman(r) + if i != j + puts "error: #{i} : #{r} - #{j}" + end +end + + +# @@PLEAC@@_2.7 +random = rand(y-x+1)+x + +chars = ["A".."Z","a".."z","0".."9"].collect { |r| r.to_a }.join + %q(!@$%^&*) +password = (1..8).collect { chars[rand(chars.size)] }.pack("C*") + + +# @@PLEAC@@_2.8 +srand # uses a combination of the time, the process id, and a sequence number +srand(val) # for repeatable behaviour + + +# @@PLEAC@@_2.9 +# from the randomr lib: +# http://raa.ruby-lang.org/project/randomr/ +----> http://raa.ruby-lang.org/project/randomr/ + +require 'random/mersenne_twister' +mers = Random::MersenneTwister.new 123456789 +puts mers.rand(0) # 0.550321932544541 +puts mers.rand(10) # 2 + +# using online sources of random data via the realrand package: +# http://raa.ruby-lang.org/project/realrand/ +# **Note** +# The following online services are used in this package: +# http://www.random.org - source: atmospheric noise +# http://www.fourmilab.ch/hotbits - source: radioactive decay timings +# http://random.hd.org - source: entropy from local and network noise +# Please visit the sites and respect the rules of each service. + +require 'random/online' + +generator1 = Random::RandomOrg.new +puts generator1.randbyte(5).join(",") +puts generator1.randnum(10, 1, 6).join(",") # Roll dice 10 times. + +generator2 = Random::FourmiLab.new +puts generator2.randbyte(5).join(",") +# randnum is not supported. + +generator3 = Random::EntropyPool.new +puts generator3.randbyte(5).join(",") +# randnum is not supported. + + +# @@PLEAC@@_2.10 +def gaussian_rand + begin + u1 = 2 * rand() - 1 + u2 = 2 * rand() - 1 + w = u1*u1 + u2*u2 + end while (w >= 1) + w = Math.sqrt((-2*Math.log(w))/w) + [ u2*w, u1*w ] +end + +mean = 25 +sdev = 2 +salary = gaussian_rand[0] * sdev + mean +printf("You have been hired at \$%.2f\n", salary) + + +# @@PLEAC@@_2.11 +def deg2rad(d) + (d/180.0)*Math::PI +end + +def rad2deg(r) + (r/Math::PI)*180 +end + + +# @@PLEAC@@_2.12 +sin_val = Math.sin(angle) +cos_val = Math.cos(angle) +tan_val = Math.tan(angle) + +# AFAIK Ruby's Math module doesn't provide acos/asin +# While we're at it, let's also define missing hyperbolic functions +module Math + def Math.asin(x) + atan2(x, sqrt(1 - x**2)) + end + def Math.acos(x) + atan2(sqrt(1 - x**2), x) + end + def Math.atan(x) + atan2(x, 1) + end + def Math.sinh(x) + (exp(x) - exp(-x)) / 2 + end + def Math.cosh(x) + (exp(x) + exp(-x)) / 2 + end + def Math.tanh(x) + sinh(x) / cosh(x) + end +end + +# The support for Complex numbers is not built-in +y = Math.acos(3.7) +#=> in `sqrt': square root for negative number (ArgumentError) + +# There is an implementation of Complex numbers in 'complex.rb' in current +# Ruby distro, but it doesn't support atan2 with complex args, so it doesn't +# solve this problem. + + +# @@PLEAC@@_2.13 +log_e = Math.log(val) +log_10 = Math.log10(val) + +def log_base(base, val) + Math.log(val)/Math.log(base) +end + +answer = log_base(10, 10_000) +puts "log10(10,000) = #{answer}" + + +# @@PLEAC@@_2.14 +require 'matrix.rb' + +a = Matrix[[3, 2, 3], [5, 9, 8]] +b = Matrix[[4, 7], [9, 3], [8, 1]] +c = a * b + +a.row_size +a.column_size + +c.det +a.transpose + + +# @@PLEAC@@_2.15 +require 'complex.rb' +require 'rational.rb' + +a = Complex(3, 5) # 3 + 5i +b = Complex(2, -2) # 2 - 2i +puts "c = #{a*b}" + +c = a * b +d = 3 + 4*Complex::I + +printf "sqrt(#{d}) = %s\n", Math.sqrt(d) + + +# @@PLEAC@@_2.16 +number = hexadecimal.hex +number = octal.oct + +print "Gimme a number in decimal, octal, or hex: " +num = gets.chomp +exit unless defined?(num) +num = num.oct if num =~ /^0/ # does both oct and hex +printf "%d %x %o\n", num, num, num + +print "Enter file permission in octal: " +permissions = gets.chomp +raise "Exiting ...\n" unless defined?(permissions) +puts "The decimal value is #{permissions.oct}" + + +# @@PLEAC@@_2.17 +def commify(n) + n.to_s =~ /([^\.]*)(\..*)?/ + int, dec = $1.reverse, $2 ? $2 : "" + while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3') + end + int.reverse + dec +end + + +# @@PLEAC@@_2.18 +printf "It took %d hour%s\n", time, time == 1 ? "" : "s" + +# dunno if an equivalent to Lingua::EN::Inflect exists... + + +# @@PLEAC@@_2.19 +#----------------------------- +#!/usr/bin/ruby +# bigfact - calculating prime factors +def factorize(orig) + factors = {} + factors.default = 0 # return 0 instead nil if key not found in hash + n = orig + i = 2 + sqi = 4 # square of i + while sqi <= n do + while n.modulo(i) == 0 do + n /= i + factors[i] += 1 + # puts "Found factor #{i}" + end + # we take advantage of the fact that (i +1)**2 = i**2 + 2*i +1 + sqi += 2 * i + 1 + i += 1 + end + + if (n != 1) && (n != orig) + factors[n] += 1 + end + factors +end + +def printfactorhash(orig, factorcount) + print format("%-10d ", orig) + if factorcount.length == 0 + print "PRIME" + else + # sorts after number, because the hash keys are numbers + factorcount.sort.each { |factor,exponent| + print factor + if exponent > 1 + print "**", exponent + end + print " " + } + end + puts +end + +for arg in ARGV + n = arg.to_i + mfactors = factorize(n) + printfactorhash(n, mfactors) +end +#----------------------------- + + +# @@PLEAC@@_3.0 +puts Time.now + +print "Today is day ", Time.now.yday, " of the current year.\n" +print "Today is day ", Time.now.day, " of the current month.\n" + + +# @@PLEAC@@_3.1 +day, month, year = Time.now.day, Time.now.month, Time.now.year +# or +day, month, year = Time.now.to_a[3..5] + +tl = Time.now.localtime +printf("The current date is %04d %02d %02d\n", tl.year, tl.month, tl.day) + +Time.now.localtime.strftime("%Y-%m-%d") + + +# @@PLEAC@@_3.2 +Time.local(year, month, day, hour, minute, second).tv_sec +Time.gm(year, month, day, hour, minute, second).tv_sec + + +# @@PLEAC@@_3.3 +sec, min, hour, day, month, year, wday, yday, isdst, zone = Time.at(epoch_secs).to_a + + +# @@PLEAC@@_3.4 +when_ = now + difference # now -> Time ; difference -> Numeric (delta in seconds) +then_ = now - difference + + +# @@PLEAC@@_3.5 +bree = 361535725 +nat = 96201950 + +difference = bree - nat +puts "There were #{difference} seconds between Nat and Bree" + +seconds = difference % 60 +difference = (difference - seconds) / 60 +minutes = difference % 60 +difference = (difference - minutes) / 60 +hours = difference % 24 +difference = (difference - hours) / 24 +days = difference % 7 +weeks = (difference - days) / 7 + +puts "(#{weeks} weeks, #{days} days, #{hours}:#{minutes}:#{seconds})" + + +# @@PLEAC@@_3.6 +monthday, weekday, yearday = date.mday, date.wday, date.yday + +# AFAIK the week number is not just a division since week boundaries are on sundays +weeknum = d.strftime("%U").to_i + 1 + +year = 1981 +month = "jun" # or `6' if you want to emulate a broken language +day = 16 +t = Time.mktime(year, month, day) +print "#{month}/#{day}/#{year} was a ", t.strftime("%A"), "\n" + + +# @@PLEAC@@_3.7 +yyyy, mm, dd = $1, $2, $3 if "1998-06-25" =~ /(\d+)-(\d+)-(\d+)/ + +epoch_seconds = Time.mktime(yyyy, mm, dd).tv_sec + +# dunno an equivalent to Date::Manip#ParseDate + + +# @@PLEAC@@_3.8 +string = Time.at(epoch_secs) +Time.at(1234567890).gmtime # gives: Fri Feb 13 23:31:30 UTC 2009 + +time = Time.mktime(1973, "jan", 18, 3, 45, 50) +print "In localtime it gives: ", time.localtime, "\n" + + +# @@PLEAC@@_3.9 +# Ruby provides micro-seconds in Time object +Time.now.usec + +# Ruby gives the seconds in floating format when substracting two Time objects +before = Time.now +line = gets +elapsed = Time.now - before +puts "You took #{elapsed} seconds." + +# On my Celeron-400 with Linux-2.2.19-14mdk, average for three execs are: +# This Ruby version: average 0.00321 sec +# Cookbook's Perl version: average 0.00981 sec +size = 500 +number_of_times = 100 +total_time = 0 +number_of_times.times { + # populate array + array = [] + size.times { array << rand } + # sort it + begin_ = Time.now + array.sort! + time = Time.now - begin_ + total_time += time +} +printf "On average, sorting %d random numbers takes %.5f seconds\n", + size, (total_time/Float(number_of_times)) + + +# @@PLEAC@@_3.10 +sleep(0.005) # Ruby is definitely not as broken as Perl :) +# (may be interrupted by sending the process a SIGALRM) + + +# @@PLEAC@@_3.11 +#!/usr/bin/ruby -w +# hopdelta - feed mail header, produce lines +# showing delay at each hop. +require 'time' +class MailHopDelta + + def initialize(mail) + @head = mail.gsub(/\n\s+/,' ') + @topline = %w-Sender Recipient Time Delta- + @start_from = mail.match(/^From.*\@([^\s>]*)/)[1] + @date = Time.parse(mail.match(/^Date:\s+(.*)/)[1]) + end + + def out(line) + "%-20.20s %-20.20s %-20.20s %s" % line + end + + def hop_date(day) + day.strftime("%I:%M:%S %Y/%m/%d") + end + + def puts_hops + puts out(@topline) + puts out(['Start', @start_from, hop_date(@date),'']) + @head.split(/\n/).reverse.grep(/^Received:/).each do |hop| + hop.gsub!(/\bon (.*?) (id.*)/,'; \1') + whence = hop.match(/;\s+(.*)$/)[1] + unless whence + warn "Bad received line: #{hop}" + next + end + from = $+ if hop =~ /from\s+(\S+)|\((.*?)\)/ + by = $1 if hop =~ /by\s+(\S+\.\S+)/ + next unless now = Time.parse(whence).localtime + delta = now - @date + puts out([from, by, hop_date(now), hop_time(delta)]) + @date = now + end + end + + def hop_time(secs) + sign = secs < 0 ? -1 : 1 + days, secs = secs.abs.divmod(60 * 60 * 24) + hours,secs = secs.abs.divmod(60 * 60) + mins, secs = secs.abs.divmod(60) + rtn = "%3ds" % [secs * sign] + rtn << "%3dm" % [mins * sign] if mins != 0 + rtn << "%3dh" % [hours * sign] if hours != 0 + rtn << "%3dd" % [days * sign] if days != 0 + rtn + end +end + +$/ = "" +mail = MailHopDelta.new(ARGF.gets).puts_hops + + +# @@PLEAC@@_4.0 +single_level = [ "this", "that", "the", "other" ] + +# Ruby directly supports nested arrays +double_level = [ "this", "that", [ "the", "other" ] ] +still_single_level = [ "this", "that", [ "the", "other" ] ].flatten + + +# @@PLEAC@@_4.1 +a = [ "quick", "brown", "fox" ] +a = %w(Why are you teasing me?) + +lines = <<"END_OF_HERE_DOC".gsub(/^\s*(.+)/, '\1') + The boy stood on the burning deck, + It was as hot as glass. +END_OF_HERE_DOC + +bigarray = IO.readlines("mydatafile").collect { |l| l.chomp } + +name = "Gandalf" +banner = %Q(Speak, #{name}, and welcome!) + +host_info = `host #{his_host}` + +%x(ps #{$$}) + +banner = 'Costs only $4.95'.split(' ') + +rax = %w! ( ) < > { } [ ] ! + + +# @@PLEAC@@_4.2 +def commify_series(arr) + return '' if not arr + case arr.size + when 0 then '' + when 1 then arr[0] + when 2 then arr.join(' and ') + else arr[0..-2].join(', ') + ', and ' + arr[-1] + end +end + +array = [ "red", "yellow", "green" ] + +print "I have ", array, " marbles\n" +# -> I have redyellowgreen marbles + +# But unlike Perl: +print "I have #{array} marbles\n" +# -> I have redyellowgreen marbles +# So, needs: +print "I have #{array.join(' ')} marbles\n" +# -> I have red yellow green marbles + +#!/usr/bin/ruby +# communify_series - show proper comma insertion in list output + +def commify_series(arr) + return '' if not arr + sepchar = arr.find { |p| p =~ /,/ } ? '; ' : ', ' + case arr.size + when 0 then '' + when 1 then arr[0] + when 2 then arr.join(' and ') + else arr[0..-2].join(sepchar) + sepchar + 'and ' + arr[-1] + end +end + +lists = [ + [ 'just one thing' ], + %w(Mutt Jeff), + %w(Peter Paul Mary), + [ 'To our parents', 'Mother Theresa', 'God' ], + [ 'pastrami', 'ham and cheese', 'peanut butter and jelly', 'tuna' ], + [ 'recycle tired, old phrases', 'ponder big, happy thoughts' ], + [ 'recycle tired, old phrases', + 'ponder big, happy thoughts', + 'sleep and dream peacefully' ], +] + +for list in lists do + puts "The list is: #{commify_series(list)}." +end + + +# @@PLEAC@@_4.3 +# (note: AFAIK Ruby doesn't allow gory change of Array length) +# grow the array by assigning nil to past the end of array +ary[new_size-1] = nil +# shrink the array by slicing it down +ary.slice!(new_size..-1) +# init the array with given size +Array.new(number_of_elems) +# assign to an element past the original end enlarges the array +ary[index_new_last_elem] = value + +def what_about_that_array(a) + print "The array now has ", a.size, " elements.\n" + # Index of last element is not really interesting in Ruby + print "Element #3 is `#{a[3]}'.\n" +end +people = %w(Crosby Stills Nash Young) +what_about_that_array(people) + + +# @@PLEAC@@_4.4 +# OO style +bad_users.each { |user| + complain(user) +} +# or, functional style +for user in bad_users + complain(user) +end + +for var in ENV.keys.sort + puts "#{var}=#{ENV[var]}" +end + +for user in all_users + disk_space = get_usage(user) + if (disk_space > MAX_QUOTA) + complain(user) + end +end + +for l in IO.popen("who").readlines + print l if l =~ /^gc/ +end + +# we can mimic the obfuscated Perl way +while fh.gets # $_ is set to the line just read + chomp # $_ has a trailing \n removed, if it had one + split.each { |w| # $_ is split on whitespace + # but $_ is not set to each chunk as in Perl + print w.reverse + } +end +# ...or use a cleaner way +for l in fh.readlines + l.chomp.split.each { |w| print w.reverse } +end + +# same drawback as in problem 1.4, we can't mutate a Numeric... +array.collect! { |v| v - 1 } + +a = [ .5, 3 ]; b = [ 0, 1 ] +for ary in [ a, b ] + ary.collect! { |v| v * 7 } +end +puts "#{a.join(' ')} #{b.join(' ')}" + +# we can mutate Strings, cool; we need a trick for the scalar +for ary in [ [ scalar ], array, hash.values ] + ary.each { |v| v.strip! } # String#strip rules :) +end + + +# @@PLEAC@@_4.5 +# not relevant in Ruby since we have always references +for item in array + # do somethingh with item +end + + +# @@PLEAC@@_4.6 +unique = list.uniq + +# generate a list of users logged in, removing duplicates +users = `who`.collect { |l| l =~ /(\w+)/; $1 }.sort.uniq +puts("users logged in: #{commify_series(users)}") # see 4.2 for commify_series + + +# @@PLEAC@@_4.7 +a - b +# [ 1, 1, 2, 2, 3, 3, 3, 4, 5 ] - [ 1, 2, 4 ] -> [3, 5] + + +# @@PLEAC@@_4.8 +union = a | b +intersection = a & b +difference = a - b + + +# @@PLEAC@@_4.9 +array1.concat(array2) +# if you will assign to another object, better use: +new_ary = array1 + array2 + +members = [ "Time", "Flies" ] +initiates = [ "An", "Arrow" ] +members += initiates + +members = [ "Time", "Flies" ] +initiates = [ "An", "Arrow" ] +members[2,0] = [ "Like", initiates ].flatten + +members[0] = "Fruit" +members[3,2] = "A", "Banana" + + +# @@PLEAC@@_4.10 +reversed = ary.reverse + +ary.reverse_each { |e| + # do something with e +} + +descending = ary.sort.reverse +descending = ary.sort { |a,b| b <=> a } + + +# @@PLEAC@@_4.11 +# remove n elements from front of ary (shift n) +front = ary.slice!(0, n) + +# remove n elements from the end of ary (pop n) +end_ = ary.slice!(-n .. -1) + +# let's extend the Array class, to make that useful +class Array + def shift2() + slice!(0 .. 1) # more symetric with pop2... + end + def pop2() + slice!(-2 .. -1) + end +end + +friends = %w(Peter Paul Mary Jim Tim) +this, that = friends.shift2 + +beverages = %w(Dew Jolt Cola Sprite Fresca) +pair = beverages.pop2 + + +# @@PLEAC@@_4.12 +# use Enumerable#detect (or the synonym Enumerable#find) +highest_eng = employees.detect { |emp| emp.category == 'engineer' } + + +# @@PLEAC@@_4.13 +# use Enumerable#select (or the synonym Enumerable#find_all) +bigs = nums.select { |i| i > 1_000_000 } +pigs = users.keys.select { |k| users[k] > 1e7 } + +matching = `who`.select { |u| u =~ /^gnat / } + +engineers = employees.select { |e| e.position == 'Engineer' } + +secondary_assistance = applicants.select { |a| + a.income >= 26_000 && a.income < 30_000 +} + + +# @@PLEAC@@_4.14 +# normally you would have an array of Numeric (Float or +# Fixnum or Bignum), so you would use: +sorted = unsorted.sort +# if you have strings representing Integers or Floats +# you may specify another sort method: +sorted = unsorted.sort { |a,b| a.to_f <=> b.to_f } + +# let's use the list of my own PID's +`ps ux`.split("\n")[1..-1]. + select { |i| i =~ /^#{ENV['USER']}/ }. + collect { |i| i.split[1] }. + sort { |a,b| a.to_i <=> b.to_i }.each { |i| puts i } +puts "Select a process ID to kill:" +pid = gets.chomp +raise "Exiting ... \n" unless pid && pid =~ /^\d+$/ +Process.kill('TERM', pid.to_i) +sleep 2 +Process.kill('KILL', pid.to_i) + +descending = unsorted.sort { |a,b| b.to_f <=> a.to_f } + + +# @@PLEAC@@_4.15 +ordered = unordered.sort { |a,b| compare(a,b) } + +precomputed = unordered.collect { |e| [compute, e] } +ordered_precomputed = precomputed.sort { |a,b| a[0] <=> b[0] } +ordered = ordered_precomputed.collect { |e| e[1] } + +ordered = unordered.collect { |e| [compute, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +for employee in employees.sort { |a,b| a.name <=> b.name } + print employee.name, " earns \$ ", employee.salary, "\n" +end + +# Beware! `0' is true in Ruby. +# For chaining comparisons, you may use Numeric#nonzero?, which +# returns num if num is not zero, nil otherwise +sorted = employees.sort { |a,b| (a.name <=> b.name).nonzero? || b.age <=> a.age } + +users = [] +# getpwent is not wrapped in Ruby... let's fallback +IO.readlines('/etc/passwd').each { |u| users << u.split(':') } +users.sort! { |a,b| a[0] <=> b[0] } +for user in users + puts user[0] +end + +sorted = names.sort { |a,b| a[1, 1] <=> b[1, 1] } +sorted = strings.sort { |a,b| a.length <=> b.length } + +# let's show only the compact version +ordered = strings.collect { |e| [e.length, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +ordered = strings.collect { |e| [/\d+/.match(e)[0].to_i, e] }. + sort { |a,b| a[0] <=> b[0] }. + collect { |e| e[1] } + +print `cat /etc/passwd`.collect { |e| [e, e.split(':').indexes(3,2,0)].flatten }. + sort { |a,b| (a[1] <=> b[1]).nonzero? || (a[2] <=> b[2]).nonzero? || a[3] <=> b[3] }. + collect { |e| e[0] } + + +# @@PLEAC@@_4.16 +circular.unshift(circular.pop) # the last shall be first +circular.push(circular.shift) # and vice versa + +def grab_and_rotate(l) + l.push(ret = l.shift) + ret +end + +processes = [1, 2, 3, 4, 5] +while (1) + process = grab_and_rotate(processes) + puts "Handling process #{process}" + sleep 1 +end + + +# @@PLEAC@@_4.17 +def fisher_yates_shuffle(a) + (a.size-1).downto(1) { |i| + j = rand(i+1) + a[i], a[j] = a[j], a[i] if i != j + } +end + +def naive_shuffle(a) + for i in 0...a.size + j = rand(a.size) + a[i], a[j] = a[j], a[i] + end +end + + + +---tokens--- +'# -*- ruby -*-' Comment.Single +'\n\n' Text + +'# Local variables:' Comment.Single +'\n' Text + +'# indent-tabs-mode: nil' Comment.Single +'\n' Text + +'# ruby-indent-level: 4' Comment.Single +'\n' Text + +'# End:' Comment.Single +'\n\n' Text + +'# @@PLEAC@@_NAME' Comment.Single +'\n' Text + +'# @@SKIP@@ Ruby' Comment.Single +'\n\n' Text + +'# @@PLEAC@@_WEB' Comment.Single +'\n' Text + +'# @@SKIP@@ http://www.ruby-lang.org' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.0' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'\\n' Literal.String.Escape +"'" Literal.String.Single +' ' Text +'# two characters, \\ and an n' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'Jon ' Literal.String.Single +"\\'" Literal.String.Escape +'Maddog' Literal.String.Single +"\\'" Literal.String.Escape +' Orwant' Literal.String.Single +"'" Literal.String.Single +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'# a "newline" character' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Jon ' Literal.String.Double +'\\"' Literal.String.Escape +'Maddog' Literal.String.Double +'\\"' Literal.String.Escape +' Orwant' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# literal double quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +"%q/Jon 'Maddog' Orwant/" Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q[' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +']' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q{' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +'}' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +')' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q<' Literal.String.Other +"Jon 'Maddog' Orwant" Literal.String.Other +'>' Literal.String.Other +' ' Text +'# literal single quotes' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +'"' Literal.String.Heredoc +'EOF' Literal.String.Delimiter +'"' Literal.String.Heredoc +'\n' Text + +'This is a multiline here document\n' Literal.String.Heredoc + +'terminated by EOF on a line by itself\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n\n' Text + +'# @@PLEAC@@_1.1' Comment.Single +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +',' Punctuation +'count' Name +']' Operator +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n\n' Text + +'string' Name +'[' Operator +'offset' Name +',' Punctuation +'count' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'newstring' Name +'\n' Text + +'string' Name +'[' Operator +'offset' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'newtail' Name +'\n\n' Text + +'# in Ruby we can also specify intervals by their two offsets' Comment.Single +'\n' Text + +'value' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'offset' Name +'..' Operator +'offs2' Name +']' Operator +'\n' Text + +'string' Name +'[' Operator +'offset' Name +'..' Operator +'offs2' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'newstring' Name +'\n\n' Text + +'leading' Name +',' Punctuation +' ' Text +'s1' Name +',' Punctuation +' ' Text +'s2' Name +',' Punctuation +' ' Text +'trailing' Name +' ' Text +'=' Operator +' ' Text +'data' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A5 x3 A8 A8 A*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'fivers' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A5' Literal.String.Double +'"' Literal.String.Double +' ' Text +'*' Operator +' ' Text +'(' Punctuation +'string' Name +'.' Operator +'length' Name +'/' Operator +'5' Literal.Number.Integer +')' Punctuation +')' Punctuation +'\n\n' Text + +'chars' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'A1' Literal.String.Double +'"' Literal.String.Double +' ' Text +'*' Operator +' ' Text +'string' Name +'.' Operator +'length' Name +')' Punctuation +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'This is what you have' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'# +012345678901234567890 Indexing forwards (left to right)' Comment.Single +'\n' Text + +'# 109876543210987654321- Indexing backwards (right to left)' Comment.Single +'\n' Text + +'# note that 0 means 10 or 20, etc. above' Comment.Single +'\n\n' Text + +'first' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "T"' Comment.Single +'\n' Text + +'start' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +']' Operator +' ' Text +'# "is"' Comment.Single +'\n' Text + +'rest' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'13' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "you have"' Comment.Single +'\n' Text + +'last' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "e"' Comment.Single +'\n' Text + +'end_' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'4' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'# "have"' Comment.Single +'\n' Text + +'piece' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'[' Operator +'-' Operator +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +' ' Text +'# "you"' Comment.Single +'\n\n' Text + +'string' Name +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +"wasn't" Literal.String.Double +'"' Literal.String.Double +' ' Text +'# change "is" to "wasn\'t"' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'-' Operator +'12' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'ondrous' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# "This wasn\'t wondrous"' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# delete first character' Comment.Single +'\n' Text + +'string' Name +'[' Operator +'-' Operator +'10' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +'# delete last 10 characters' Comment.Single +'\n\n' Text + +'if' Keyword +' ' Text +'string' Name +'[' Operator +'-' Operator +'10' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'pattern' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Pattern matches in last 10 characters' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'string' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'is' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'at' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'make a hat' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'a' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'To be or not to be' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'x6 A6' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'b' Name +',' Punctuation +' ' Text +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'x6 A2 X5 A2' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'#{' Literal.String.Interpol +'c' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n' Text + +'def' Keyword +' ' Text +'cut2fmt' Name.Function +'(' Punctuation +'*' Operator +'args' Name +')' Punctuation +'\n ' Text +'template' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'lastpos' Name +' ' Text +'=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'for' Keyword +' ' Text +'place' Name +' ' Text +'in' Keyword +' ' Text +'args' Name +'\n ' Text +'template' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +' ' Text +'+' Operator +' ' Text +'(' Punctuation +'place' Name +' ' Text +'-' Operator +' ' Text +'lastpos' Name +')' Punctuation +'.' Operator +'to_s' Name +' ' Text +'+' Operator +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'lastpos' Name +' ' Text +'=' Operator +' ' Text +'place' Name +'\n ' Text +'end' Keyword +'\n ' Text +'template' Name +' ' Text +'+=' Operator +' ' Text +'"' Literal.String.Double +'A*' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'return' Keyword +' ' Text +'template' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'fmt' Name +' ' Text +'=' Operator +' ' Text +'cut2fmt' Name +'(' Punctuation +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'14' Literal.Number.Integer +',' Punctuation +' ' Text +'20' Literal.Number.Integer +',' Punctuation +' ' Text +'26' Literal.Number.Integer +',' Punctuation +' ' Text +'30' Literal.Number.Integer +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.2' Comment.Single +'\n' Text + +'# careful! "b is true" doesn\'t mean "b != 0" (0 is true in Ruby)' Comment.Single +'\n' Text + +'# thus no problem of "defined" later since only nil is false' Comment.Single +'\n' Text + +"# the following sets to `c' if `b' is nil or false" Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +' ' Text +'||' Operator +' ' Text +'c' Name +'\n\n' Text + +"# if you need Perl's behaviour (setting to `c' if `b' is 0) the most" Comment.Single +'\n' Text + +'# effective way is to use Numeric#nonzero? (thanks to Dave Thomas!)' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'b' Name +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'c' Name +'\n\n' Text + +'# you will still want to use defined? in order to test' Comment.Single +'\n' Text + +'# for scope existence of a given object' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'defined?' Name +'(' Punctuation +'b' Name +')' Punctuation +' ' Text +'?' Punctuation +' ' Text +'b' Name +' ' Text +':' Punctuation +' ' Text +'c' Name +'\n\n' Text + +'dir' Name +' ' Text +'=' Operator +' ' Text +'ARGV' Name.Constant +'.' Operator +'shift' Name +' ' Text +'||' Operator +' ' Text +'"' Literal.String.Double +'/tmp' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_1.3' Comment.Single +'\n' Text + +'v1' Name +',' Punctuation +' ' Text +'v2' Name +' ' Text +'=' Operator +' ' Text +'v2' Name +',' Punctuation +' ' Text +'v1' Name +'\n\n' Text + +'alpha' Name +',' Punctuation +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'January March August' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'alpha' Name +',' Punctuation +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +' ' Text +'=' Operator +' ' Text +'beta' Name +',' Punctuation +' ' Text +'production' Name +',' Punctuation +' ' Text +'alpha' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.4' Comment.Single +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'char' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'char' Name +' ' Text +'=' Operator +' ' Text +'num' Name +'.' Operator +'chr' Name +'\n\n' Text + +'# Ruby also supports having a char from character constant' Comment.Single +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'?r' Literal.String.Char +'\n\n' Text + +'char' Name +' ' Text +'=' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%c' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +')' Punctuation +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'Number %d is character %c' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +')' Punctuation +'\n\n' Text + +'ascii' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'ascii' Name +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'hal' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'HAL' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'ascii' Name +' ' Text +'=' Operator +' ' Text +'hal' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +"# We can't use Array#each since we can't mutate a Fixnum" Comment.Single +'\n' Text + +'ascii' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'# add one to each ASCII value' Comment.Single +'\n' Text + +'}' Punctuation +' \n' Text + +'ibm' Name +' ' Text +'=' Operator +' ' Text +'ascii' Name +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'ibm' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.5' Comment.Single +'\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'string' Name +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'.' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'b' Name +'|' Operator +'\n ' Text +'# do something with b' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'an apple a day' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'unique chars are: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'uniq' Name +'.' Operator +'sort' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n' Text + +'sum' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'for' Keyword +' ' Text +'ascval' Name +' ' Text +'in' Keyword +' ' Text +'string' Name +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# or use Array#each for a pure OO style :)' Comment.Single +'\n ' Text +'sum' Name +' ' Text +'+=' Operator +' ' Text +'ascval' Name +'\n' Text + +'end' Keyword +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'sum is ' Literal.String.Double +'#{' Literal.String.Interpol +'sum' Name +' ' Text +'&' Operator +' ' Text +'0xffffffff' Literal.Number.Hex +'}' Literal.String.Interpol +'"' Literal.String.Double +' ' Text +'# since Ruby will go Bignum if necessary' Comment.Single +'\n\n' Text + +'# @@INCLUDE@@ include/ruby/slowcat.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.6' Comment.Single +'\n' Text + +'revbytes' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'reverse' Name +'\n\n' Text + +'revwords' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n' Text + +'revwords' Name +' ' Text +'=' Operator +' ' Text +'string' Name +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'s+)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'join' Name +'\n\n' Text + +'# using the fact that IO is Enumerable, you can directly "select" it' Comment.Single +'\n' Text + +'long_palindromes' Name +' ' Text +'=' Operator +' ' Text +'File' Name.Constant +'.' Operator +'open' Name +'(' Punctuation +'"' Literal.String.Double +'/usr/share/dict/words' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'\n ' Text +'select' Name.Builtin +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'w' Name +'.' Operator +'chomp!' Name +';' Punctuation +' ' Text +'w' Name +'.' Operator +'reverse' Name +' ' Text +'==' Operator +' ' Text +'w' Name +' ' Text +'&&' Operator +' ' Text +'w' Name +'.' Operator +'length' Name +' ' Text +'>' Operator +' ' Text +'5' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.7' Comment.Single +'\n' Text + +'while' Keyword +' ' Text +'string' Name +'.' Operator +'sub!' Name +'(' Punctuation +'"' Literal.String.Double +'\\t' Literal.String.Escape +'+' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'*' Operator +' ' Text +'(' Punctuation +'$&' Name.Variable.Global +'.' Operator +'length' Name +' ' Text +'*' Operator +' ' Text +'8' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'$`' Name.Variable.Global +'.' Operator +'length' Name +' ' Text +'%' Operator +' ' Text +'8' Literal.Number.Integer +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_1.8' Comment.Single +'\n' Text + +"'" Literal.String.Single +'You owe ' Literal.String.Single +'#{' Literal.String.Interpol +'debt' Name +'}' Literal.String.Interpol +' to me' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'#{' Literal.String.Interpol +'(' Punctuation +'\\' Punctuation +'w' Name +'+' Operator +')' Punctuation +'}' Literal.String.Interpol +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'eval' Name.Builtin +'(' Punctuation +'$1' Name.Variable.Global +')' Punctuation +' ' Text +'}' Punctuation +'\n\n' Text + +'rows' Name +',' Punctuation +' ' Text +'cols' Name +' ' Text +'=' Operator +' ' Text +'24' Literal.Number.Integer +',' Punctuation +' ' Text +'80' Literal.Number.Integer +'\n' Text + +'text' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +'I am ' Literal.String.Other +'#' Literal.String.Other +'{rows} high and ' Literal.String.Other +'#' Literal.String.Other +'{cols} long' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'text' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'#{' Literal.String.Interpol +'(' Punctuation +'\\' Punctuation +'w' Name +'+' Operator +')' Punctuation +'}' Literal.String.Interpol +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'eval' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'#{' Literal.String.Interpol +'$1' Name.Variable.Global +'}' Literal.String.Interpol +'"' Literal.String.Double +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'text' Name +'\n\n' Text + +"'" Literal.String.Single +'I am 17 years old' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'$&' Name.Variable.Global +'.' Operator +'to_i' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.9' Comment.Single +'\n' Text + +'e' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'bo peep' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'upcase' Name +'\n' Text + +'e' Name +'.' Operator +'downcase!' Name +'\n' Text + +'e' Name +'.' Operator +'capitalize!' Name +'\n\n' Text + +'"' Literal.String.Double +'thIS is a loNG liNE' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'w+' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'$&' Name.Variable.Global +'.' Operator +'capitalize' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.10' Comment.Single +'\n' Text + +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'n' Name +'+' Operator +'1' Literal.Number.Integer +'}' Literal.String.Interpol +' guanacos.' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'n' Name +'+' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +' guanacos.' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_1.11' Comment.Single +'\n' Text + +'var' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +"'" Literal.String.Heredoc +'EOF' Literal.String.Delimiter +"'" Literal.String.Heredoc +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'s+' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +' your text\n' Literal.String.Heredoc + +' goes here\n' Literal.String.Heredoc + +'EOF\n' Literal.String.Delimiter + +'\n\n' Text + +'# @@PLEAC@@_1.12' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Folding and splicing is the work of an editor,' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +'\n ' Text +'"' Literal.String.Double +'not a mere collection of silicon' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +' \n ' Text +'"' Literal.String.Double +'and' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'+' Operator +'\n ' Text +'"' Literal.String.Double +'mobile electrons!' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'def' Keyword +' ' Text +'wrap' Name.Function +'(' Punctuation +'str' Name +',' Punctuation +' ' Text +'max_size' Name +')' Punctuation +'\n ' Text +'all' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'line' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'str' Name +'.' Operator +'split' Name +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'line' Name +'+' Operator +'l' Name +')' Punctuation +'.' Operator +'length' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'max_size' Name +'\n ' Text +'all' Name +'.' Operator +'push' Name +'(' Punctuation +'line' Name +')' Punctuation +'\n ' Text +'line' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'end' Keyword +'\n ' Text +'line' Name +' ' Text +'+=' Operator +' ' Text +'line' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'?' Punctuation +' ' Text +'l' Name +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'l' Name +'\n ' Text +'end' Keyword +'\n ' Text +'all' Name +'.' Operator +'push' Name +'(' Punctuation +'line' Name +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'print' Name.Builtin +' ' Text +'wrap' Name +'(' Punctuation +'string' Name +',' Punctuation +' ' Text +'20' Literal.Number.Integer +')' Punctuation +'\n' Text + +'#=> Folding and ' Comment.Single +'\n' Text + +'#=> splicing is the ' Comment.Single +'\n' Text + +'#=> work of an editor, ' Comment.Single +'\n' Text + +'#=> not a mere ' Comment.Single +'\n' Text + +'#=> collection of ' Comment.Single +'\n' Text + +'#=> silicon and mobile ' Comment.Single +'\n' Text + +'#=> electrons!' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.13' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'%q(' Literal.String.Other +'Mom said, "Don\'t do that."' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[\'"]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[\'"]' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\' Literal.String.Single +'&' Literal.String.Single +'\\' Literal.String.Single +'&' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'string' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'[^A-Z]' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +'\n' Text + +'"' Literal.String.Double +'is a test!' Literal.String.Double +'"' Literal.String.Double +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'W' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +"'" Literal.String.Single +'\\\\' Literal.String.Escape +"'" Literal.String.Single +'+' Operator +'$&' Name.Variable.Global +' ' Text +'}' Punctuation +' ' Text +'# no function like quotemeta?' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.14' Comment.Single +'\n' Text + +'string' Name +'.' Operator +'strip!' Name +'\n\n\n' Text + +'# @@PLEAC@@_1.15' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'parse_csv' Name.Function +'(' Punctuation +'text' Name +')' Punctuation +'\n ' Text +'new' Keyword.Pseudo +' ' Text +'=' Operator +' ' Text +'text' Name +'.' Operator +'scan' Name +'(' Punctuation +'/' Literal.String.Regex +'"([^' Literal.String.Regex +'\\' Literal.String.Regex +'"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*(?:' Literal.String.Regex +'\\\\' Literal.String.Regex +'.[^' Literal.String.Regex +'\\' Literal.String.Regex +'"' Literal.String.Regex +'\\\\' Literal.String.Regex +']*)*)",?|([^,]+),?|,' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'new' Keyword.Pseudo +' ' Text +'<<' Operator +' ' Text +'nil' Keyword.Pseudo +' ' Text +'if' Keyword +' ' Text +'text' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'==' Operator +' ' Text +'?,' Literal.String.Char +'\n ' Text +'new' Keyword.Pseudo +'.' Operator +'flatten' Name +'.' Operator +'compact' Name +'\n' Text + +'end' Keyword +' \n\n' Text + +'line' Name +' ' Text +'=' Operator +' ' Text +'%q<' Literal.String.Other +'XYZZY,"","O\'Reilly, Inc","Wall, Larry","a ' Literal.String.Other +'\\' Literal.String.Other +'"glug' Literal.String.Other +'\\' Literal.String.Other +'" bit,",5,"Error, Core Dumped"' Literal.String.Other +'>' Literal.String.Other +'\n' Text + +'fields' Name +' ' Text +'=' Operator +' ' Text +'parse_csv' Name +'(' Punctuation +'line' Name +')' Punctuation +'\n' Text + +'fields' Name +'.' Operator +'each_with_index' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +',' Punctuation +'i' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +' : ' Literal.String.Double +'#{' Literal.String.Interpol +'v' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +';' Punctuation +'\n' Text + +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_1.16' Comment.Single +'\n' Text + +'# Use the soundex.rb Library from Michael Neumann.' Comment.Single +'\n' Text + +'# http://www.s-direktnet.de/homepages/neumann/rb_prgs/Soundex.rb' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'Soundex' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'code' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'string' Name +')' Punctuation +'\n' Text + +'codes' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'array' Name +')' Punctuation +'\n\n' Text + +'# substitution function for getpwent():' Comment.Single +'\n' Text + +'# returns an array of user entries,' Comment.Single +'\n' Text + +'# each entry contains the username and the full name' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'login_names' Name.Function +'\n ' Text +'result' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'File' Name.Constant +'.' Operator +'open' Name +'(' Punctuation +'"' Literal.String.Double +'/etc/passwd' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'file' Name +'|' Operator +'\n ' Text +'file' Name +'.' Operator +'each_line' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'line' Name +'|' Operator +'\n ' Text +'next' Keyword +' ' Text +'if' Keyword +' ' Text +'line' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'#' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'\n ' Text +'cols' Name +' ' Text +'=' Operator +' ' Text +'line' Name +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +':' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'result' Name +'.' Operator +'push' Name +'(' Punctuation +'[' Operator +'cols' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'cols' Name +'[' Operator +'4' Literal.Number.Integer +']' Operator +']' Operator +')' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'}' Punctuation +'\n ' Text +'result' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Lookup user: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'user' Name +' ' Text +'=' Operator +' ' Text +'STDIN' Name.Constant +'.' Operator +'gets' Name +'\n' Text + +'user' Name +'.' Operator +'chomp!' Name +'\n' Text + +'exit' Name.Builtin +' ' Text +'unless' Keyword +' ' Text +'user' Name +'\n' Text + +'name_code' Name +' ' Text +'=' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n\n' Text + +'splitter' Name +' ' Text +'=' Operator +' ' Text +'Regexp' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +"'" Literal.String.Single +'(' Literal.String.Single +'\\' Literal.String.Single +'w+)[^,]*' Literal.String.Single +'\\b' Literal.String.Escape +'(' Literal.String.Single +'\\' Literal.String.Single +'w+)' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'for' Keyword +' ' Text +'username' Name +',' Punctuation +' ' Text +'fullname' Name +' ' Text +'in' Keyword +' ' Text +'login_names' Name +' ' Text +'do' Keyword +'\n ' Text +'firstname' Name +',' Punctuation +' ' Text +'lastname' Name +' ' Text +'=' Operator +' ' Text +'splitter' Name +'.' Operator +'match' Name +'(' Punctuation +'fullname' Name +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +']' Operator +'\n ' Text +'if' Keyword +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'username' Name +')' Punctuation +'\n ' Text +'||' Operator +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'firstname' Name +')' Punctuation +'\n ' Text +'||' Operator +' ' Text +'name_code' Name +' ' Text +'==' Operator +' ' Text +'Text' Name.Constant +'::' Operator +'Soundex' Name.Constant +'.' Operator +'soundex' Name +'(' Punctuation +'lastname' Name +')' Punctuation +'\n ' Text +'then' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'username' Name +'}' Literal.String.Interpol +': ' Literal.String.Double +'#{' Literal.String.Interpol +'firstname' Name +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'lastname' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_1.17' Comment.Single +'\n' Text + +'# @@INCLUDE@@ include/ruby/fixstyle.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_1.18' Comment.Single +'\n' Text + +'# @@INCLUDE@@ include/ruby/psgrep.rb' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.1' Comment.Single +'\n' Text + +'# Matz tells that you can use Integer() for strict checked conversion.' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'abc' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> `Integer\': invalid value for Integer: "abc" (ArgumentError)' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'567' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> 567' Comment.Single +'\n\n' Text + +'# You may use Float() for floating point stuff' Comment.Single +'\n' Text + +'Integer' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'56.7' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> `Integer\': invalid value for Integer: "56.7" (ArgumentError)' Comment.Single +'\n' Text + +'Float' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'56.7' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'#=> 56.7' Comment.Single +'\n\n' Text + +'# You may also use a regexp for that' Comment.Single +'\n' Text + +'if' Keyword +' ' Text +'string' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^[+-]?' Literal.String.Regex +'\\' Literal.String.Regex +'d+$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is an integer' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'else' Keyword +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is not' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'if' Keyword +' ' Text +'string' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^-?(?:' Literal.String.Regex +'\\' Literal.String.Regex +'d+(?:' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'d*)?|' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'d+)$' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is a decimal number' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'else' Keyword +'\n ' Text +'p' Name.Builtin +' ' Text +"'" Literal.String.Single +'is not' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.2' Comment.Single +'\n' Text + +'# equal(num1, num2, accuracy) : returns true if num1 and num2 are' Comment.Single +'\n' Text + +'# equal to accuracy number of decimal places' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'equal' Name.Function +'(' Punctuation +'i' Name +',' Punctuation +' ' Text +'j' Name +',' Punctuation +' ' Text +'a' Name +')' Punctuation +'\n ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'g' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'i' Name +')' Punctuation +' ' Text +'==' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'g' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'j' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'wage' Name +' ' Text +'=' Operator +' ' Text +'536' Literal.Number.Integer +' ' Text +'# $5.36/hour' Comment.Single +'\n' Text + +'week' Name +' ' Text +'=' Operator +' ' Text +'40' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'wage' Name +' ' Text +'# $214.40' Comment.Single +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +"One week's wage is: " Literal.String.Double +'\\' Literal.String.Double +'$%.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'week' Name +'/' Operator +'100' Literal.Number.Integer +'.' Operator +'0' Literal.Number.Integer +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.3' Comment.Single +'\n' Text + +'num' Name +'.' Operator +'round' Name +' ' Text +'# rounds to integer' Comment.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'.' Operator +'255' Literal.Number.Integer +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'sprintf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%.2f' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Unrounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'Rounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'Unrounded: ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'}' Literal.String.Interpol +'\\n' Literal.String.Escape +'Rounded: %.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'number' Literal.String.Double +'\\t' Literal.String.Escape +'int' Literal.String.Double +'\\t' Literal.String.Escape +'floor' Literal.String.Double +'\\t' Literal.String.Escape +'ceil' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'3' Literal.Number.Integer +'.' Operator +'3' Literal.Number.Integer +' ' Text +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'.' Operator +'5' Literal.Number.Integer +' ' Text +',' Punctuation +' ' Text +'3' Literal.Number.Integer +'.' Operator +'7' Literal.Number.Integer +',' Punctuation +' ' Text +'-' Operator +'3' Literal.Number.Integer +'.' Operator +'3' Literal.Number.Integer +' ' Text +']' Operator +'\n' Text + +'for' Keyword +' ' Text +'n' Name +' ' Text +'in' Keyword +' ' Text +'a' Name +'\n ' Text +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\t' Literal.String.Escape +'% .1f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +"# at least I don't fake my output :)" Comment.Single +'\n ' Text +'n' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'to_i' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'floor' Name +',' Punctuation +' ' Text +'n' Name +'.' Operator +'ceil' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.4' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'dec2bin' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'[' Operator +'n' Name +']' Operator +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'N' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'B32' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'sub' Name +'(' Punctuation +'/' Literal.String.Regex +'^0+(?=' Literal.String.Regex +'\\' Literal.String.Regex +'d)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'bin2dec' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'[' Operator +'(' Punctuation +'"' Literal.String.Double +'0' Literal.String.Double +'"' Literal.String.Double +'*' Operator +'32' Literal.Number.Integer +'+' Operator +'n' Name +'.' Operator +'to_s' Name +')' Punctuation +'[' Operator +'-' Operator +'32' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +']' Operator +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'B32' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'unpack' Name +'(' Punctuation +'"' Literal.String.Double +'N' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.5' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'x' Name +' ' Text +'..' Operator +' ' Text +'y' Name +'\n ' Text +'# i is set to every integer from x to y, inclusive' Comment.Single +'\n' Text + +'end' Keyword +'\n\n' Text + +'x' Name +'.' Operator +'step' Name +'(' Punctuation +'y' Name +',' Punctuation +'7' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'# i is set to every integer from x to y, stepsize = 7' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Infancy is: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'(' Punctuation +'0' Literal.Number.Integer +'..' Operator +'2' Literal.Number.Integer +')' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'i' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'}' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.6' Comment.Single +'\n' Text + +'# We can add conversion methods to the Integer class,' Comment.Single +'\n' Text + +'# this makes a roman number just a representation for normal numbers.' Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Integer' Name.Class +'\n \n ' Text +'@@romanlist' Name.Variable.Class +' ' Text +'=' Operator +' ' Text +'[' Operator +'[' Operator +'"' Literal.String.Double +'M' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'1000' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'CM' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'900' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'D' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'500' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'CD' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'400' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'C' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'100' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'XC' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'90' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'L' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'50' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'XL' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'40' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'X' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'10' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'IX' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'9' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'V' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'IV' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'4' Literal.Number.Integer +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +'"' Literal.String.Double +'I' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +']' Operator +'\n \n ' Text +'def' Keyword +' ' Text +'to_roman' Name.Function +'\n ' Text +'remains' Name +' ' Text +'=' Operator +' ' Text +'self' Name.Builtin +'\n ' Text +'roman' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'for' Keyword +' ' Text +'sym' Name +',' Punctuation +' ' Text +'num' Name +' ' Text +'in' Keyword +' ' Text +'@@romanlist' Name.Variable.Class +'\n ' Text +'while' Keyword +' ' Text +'remains' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'num' Name +'\n ' Text +'remains' Name +' ' Text +'-=' Operator +' ' Text +'num' Name +'\n ' Text +'roman' Name +' ' Text +'<<' Operator +' ' Text +'sym' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'roman' Name +'\n ' Text +'end' Keyword +'\n \n ' Text +'def' Keyword +' ' Text +'Integer' Name.Class +'.' Operator +'from_roman' Name.Function +'(' Punctuation +'roman' Name +')' Punctuation +'\n ' Text +'ustr' Name +' ' Text +'=' Operator +' ' Text +'roman' Name +'.' Operator +'upcase' Name +'\n ' Text +'sum' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'for' Keyword +' ' Text +'entry' Name +' ' Text +'in' Keyword +' ' Text +'@@romanlist' Name.Variable.Class +'\n ' Text +'sym' Name +',' Punctuation +' ' Text +'num' Name +' ' Text +'=' Operator +' ' Text +'entry' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'entry' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'while' Keyword +' ' Text +'sym' Name +' ' Text +'==' Operator +' ' Text +'ustr' Name +'[' Operator +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'sym' Name +'.' Operator +'length' Name +']' Operator +'\n ' Text +'sum' Name +' ' Text +'+=' Operator +' ' Text +'num' Name +'\n ' Text +'ustr' Name +'.' Operator +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'sym' Name +'.' Operator +'length' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'sum' Name +'\n ' Text +'end' Keyword +'\n \n' Text + +'end' Keyword +'\n\n\n' Text + +'roman_fifteen' Name +' ' Text +'=' Operator +' ' Text +'15' Literal.Number.Integer +'.' Operator +'to_roman' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Roman for fifteen is ' Literal.String.Double +'#{' Literal.String.Interpol +'roman_fifteen' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'i' Name +' ' Text +'=' Operator +' ' Text +'Integer' Name.Builtin +'.' Operator +'from_roman' Name +'(' Punctuation +'roman_fifteen' Name +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Converted back, ' Literal.String.Double +'#{' Literal.String.Interpol +'roman_fifteen' Name +'}' Literal.String.Interpol +' is ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'# check' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +'..' Operator +'3900' Literal.Number.Integer +')' Punctuation +'\n ' Text +'r' Name +' ' Text +'=' Operator +' ' Text +'i' Name +'.' Operator +'to_roman' Name +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'Integer' Name.Builtin +'.' Operator +'from_roman' Name +'(' Punctuation +'r' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'!=' Operator +' ' Text +'j' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'error: ' Literal.String.Double +'#{' Literal.String.Interpol +'i' Name +'}' Literal.String.Interpol +' : ' Literal.String.Double +'#{' Literal.String.Interpol +'r' Name +'}' Literal.String.Interpol +' - ' Literal.String.Double +'#{' Literal.String.Interpol +'j' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.7' Comment.Single +'\n' Text + +'random' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'y' Name +'-' Operator +'x' Name +'+' Operator +'1' Literal.Number.Integer +')' Punctuation +'+' Operator +'x' Name +'\n\n' Text + +'chars' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'Z' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +'"' Literal.String.Double +'a' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'z' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +'"' Literal.String.Double +'0' Literal.String.Double +'"' Literal.String.Double +'..' Operator +'"' Literal.String.Double +'9' Literal.String.Double +'"' Literal.String.Double +']' Operator +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'r' Name +'|' Operator +' ' Text +'r' Name +'.' Operator +'to_a' Name +' ' Text +'}' Punctuation +'.' Operator +'join' Name +' ' Text +'+' Operator +' ' Text +'%q(' Literal.String.Other +'!@$%^&*' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'password' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +'..' Operator +'8' Literal.Number.Integer +')' Punctuation +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'chars' Name +'[' Operator +'rand' Name.Builtin +'(' Punctuation +'chars' Name +'.' Operator +'size' Name +')' Punctuation +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'pack' Name +'(' Punctuation +'"' Literal.String.Double +'C*' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.8' Comment.Single +'\n' Text + +'srand' Name.Builtin +' ' Text +'# uses a combination of the time, the process id, and a sequence number' Comment.Single +'\n' Text + +'srand' Name.Builtin +'(' Punctuation +'val' Name +')' Punctuation +' ' Text +'# for repeatable behaviour' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.9' Comment.Single +'\n' Text + +'# from the randomr lib: ' Comment.Single +'\n' Text + +'# http://raa.ruby-lang.org/project/randomr/' Comment.Single +'\n' Text + +'-' Operator +'-' Operator +'-' Operator +'-' Operator +'>' Operator +' ' Text +'http' Literal.String.Symbol +':' Punctuation +'/' Literal.String.Regex +'/' Literal.String.Regex +'raa' Name +'.' Operator +'ruby' Name +'-' Operator +'lang' Name +'.' Operator +'org' Name +'/' Operator +'project' Name +'/' Operator +'randomr' Name +'/' Operator +'\n\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'random/mersenne_twister' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'mers' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'MersenneTwister' Name.Constant +'.' Operator +'new' Name +' ' Text +'123456789' Literal.Number.Integer +'\n' Text + +'puts' Name.Builtin +' ' Text +'mers' Name +'.' Operator +'rand' Name +'(' Punctuation +'0' Literal.Number.Integer +')' Punctuation +' ' Text +'# 0.550321932544541' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'mers' Name +'.' Operator +'rand' Name +'(' Punctuation +'10' Literal.Number.Integer +')' Punctuation +' ' Text +'# 2' Comment.Single +'\n\n' Text + +'# using online sources of random data via the realrand package:' Comment.Single +'\n' Text + +'# http://raa.ruby-lang.org/project/realrand/' Comment.Single +'\n' Text + +'# **Note**' Comment.Single +'\n' Text + +'# The following online services are used in this package:' Comment.Single +'\n' Text + +'# http://www.random.org - source: atmospheric noise ' Comment.Single +'\n' Text + +'# http://www.fourmilab.ch/hotbits - source: radioactive decay timings' Comment.Single +'\n' Text + +'# http://random.hd.org - source: entropy from local and network noise' Comment.Single +'\n' Text + +'# Please visit the sites and respect the rules of each service.' Comment.Single +'\n\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'random/online' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'generator1' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'RandomOrg' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator1' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator1' Name +'.' Operator +'randnum' Name +'(' Punctuation +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'6' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +' ' Text +'# Roll dice 10 times.' Comment.Single +'\n\n' Text + +'generator2' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'FourmiLab' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator2' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'# randnum is not supported.' Comment.Single +'\n\n' Text + +'generator3' Name +' ' Text +'=' Operator +' ' Text +'Random' Name.Constant +'::' Operator +'EntropyPool' Name.Constant +'.' Operator +'new' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'generator3' Name +'.' Operator +'randbyte' Name +'(' Punctuation +'5' Literal.Number.Integer +')' Punctuation +'.' Operator +'join' Name +'(' Punctuation +'"' Literal.String.Double +',' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n' Text + +'# randnum is not supported.' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.10' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'gaussian_rand' Name.Function +'\n ' Text +'begin' Keyword +'\n ' Text +'u1' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'u2' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +')' Punctuation +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'u1' Name +'*' Operator +'u1' Name +' ' Text +'+' Operator +' ' Text +'u2' Name +'*' Operator +'u2' Name +'\n ' Text +'end' Keyword +' ' Text +'while' Keyword +' ' Text +'(' Punctuation +'w' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'w' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'sqrt' Name +'(' Punctuation +'(' Punctuation +'-' Operator +'2' Literal.Number.Integer +'*' Operator +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'w' Name +')' Punctuation +')' Punctuation +'/' Operator +'w' Name +')' Punctuation +'\n ' Text +'[' Operator +' ' Text +'u2' Name +'*' Operator +'w' Name +',' Punctuation +' ' Text +'u1' Name +'*' Operator +'w' Name +' ' Text +']' Operator +'\n' Text + +'end' Keyword +'\n\n' Text + +'mean' Name +' ' Text +'=' Operator +' ' Text +'25' Literal.Number.Integer +'\n' Text + +'sdev' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'salary' Name +' ' Text +'=' Operator +' ' Text +'gaussian_rand' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'*' Operator +' ' Text +'sdev' Name +' ' Text +'+' Operator +' ' Text +'mean' Name +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'You have been hired at ' Literal.String.Double +'\\' Literal.String.Double +'$%.2f' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'salary' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.11' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'deg2rad' Name.Function +'(' Punctuation +'d' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'d' Name +'/' Operator +'180' Literal.Number.Integer +'.' Operator +'0' Literal.Number.Integer +')' Punctuation +'*' Operator +'Math' Name.Constant +'::' Operator +'PI' Name.Constant +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'rad2deg' Name.Function +'(' Punctuation +'r' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'r' Name +'/' Operator +'Math' Name.Constant +'::' Operator +'PI' Name.Constant +')' Punctuation +'*' Operator +'180' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.12' Comment.Single +'\n' Text + +'sin_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'sin' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n' Text + +'cos_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'cos' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n' Text + +'tan_val' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'tan' Name +'(' Punctuation +'angle' Name +')' Punctuation +'\n\n' Text + +"# AFAIK Ruby's Math module doesn't provide acos/asin" Comment.Single +'\n' Text + +"# While we're at it, let's also define missing hyperbolic functions" Comment.Single +'\n' Text + +'module' Keyword +' ' Text +'Math' Name.Namespace +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'asin' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'sqrt' Name +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'x' Name +'**' Operator +'2' Literal.Number.Integer +')' Punctuation +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'acos' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'sqrt' Name +'(' Punctuation +'1' Literal.Number.Integer +' ' Text +'-' Operator +' ' Text +'x' Name +'**' Operator +'2' Literal.Number.Integer +')' Punctuation +',' Punctuation +' ' Text +'x' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'atan' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'atan2' Name +'(' Punctuation +'x' Name +',' Punctuation +' ' Text +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'sinh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'exp' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'-' Operator +' ' Text +'exp' Name +'(' Punctuation +'-' Operator +'x' Name +')' Punctuation +')' Punctuation +' ' Text +'/' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'cosh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'exp' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'+' Operator +' ' Text +'exp' Name +'(' Punctuation +'-' Operator +'x' Name +')' Punctuation +')' Punctuation +' ' Text +'/' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'Math' Name.Class +'.' Operator +'tanh' Name.Function +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'sinh' Name +'(' Punctuation +'x' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'cosh' Name +'(' Punctuation +'x' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'# The support for Complex numbers is not built-in' Comment.Single +'\n' Text + +'y' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'acos' Name +'(' Punctuation +'3' Literal.Number.Integer +'.' Operator +'7' Literal.Number.Integer +')' Punctuation +'\n' Text + +"#=> in `sqrt': square root for negative number (ArgumentError)" Comment.Single +'\n\n' Text + +"# There is an implementation of Complex numbers in 'complex.rb' in current" Comment.Single +'\n' Text + +"# Ruby distro, but it doesn't support atan2 with complex args, so it doesn't" Comment.Single +'\n' Text + +'# solve this problem.' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.13' Comment.Single +'\n' Text + +'log_e' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'val' Name +')' Punctuation +'\n' Text + +'log_10' Name +' ' Text +'=' Operator +' ' Text +'Math' Name.Constant +'.' Operator +'log10' Name +'(' Punctuation +'val' Name +')' Punctuation +'\n\n' Text + +'def' Keyword +' ' Text +'log_base' Name.Function +'(' Punctuation +'base' Name +',' Punctuation +' ' Text +'val' Name +')' Punctuation +'\n ' Text +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'val' Name +')' Punctuation +'/' Operator +'Math' Name.Constant +'.' Operator +'log' Name +'(' Punctuation +'base' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'answer' Name +' ' Text +'=' Operator +' ' Text +'log_base' Name +'(' Punctuation +'10' Literal.Number.Integer +',' Punctuation +' ' Text +'10_000' Literal.Number.Integer +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'log10(10,000) = ' Literal.String.Double +'#{' Literal.String.Interpol +'answer' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.14' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'matrix.rb' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'Matrix' Name.Constant +'[' Operator +'[' Operator +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'9' Literal.Number.Integer +',' Punctuation +' ' Text +'8' Literal.Number.Integer +']' Operator +']' Operator +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'Matrix' Name.Constant +'[' Operator +'[' Operator +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'7' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'9' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +']' Operator +',' Punctuation +' ' Text +'[' Operator +'8' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +']' Operator +'\n' Text + +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'*' Operator +' ' Text +'b' Name +'\n\n' Text + +'a' Name +'.' Operator +'row_size' Name +'\n' Text + +'a' Name +'.' Operator +'column_size' Name +'\n\n' Text + +'c' Name +'.' Operator +'det' Name +'\n' Text + +'a' Name +'.' Operator +'transpose' Name +'\n\n\n' Text + +'# @@PLEAC@@_2.15' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'complex.rb' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'rational.rb' Literal.String.Single +"'" Literal.String.Single +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'Complex' Name.Constant +'(' Punctuation +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +')' Punctuation +' ' Text +'# 3 + 5i' Comment.Single +'\n' Text + +'b' Name +' ' Text +'=' Operator +' ' Text +'Complex' Name.Constant +'(' Punctuation +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'-' Operator +'2' Literal.Number.Integer +')' Punctuation +' ' Text +'# 2 - 2i' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'c = ' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'*' Operator +'b' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'c' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'*' Operator +' ' Text +'b' Name +'\n' Text + +'d' Name +' ' Text +'=' Operator +' ' Text +'3' Literal.Number.Integer +' ' Text +'+' Operator +' ' Text +'4' Literal.Number.Integer +'*' Operator +'Complex' Name.Constant +'::' Operator +'I' Name +'\n\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'sqrt(' Literal.String.Double +'#{' Literal.String.Interpol +'d' Name +'}' Literal.String.Interpol +') = %s' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'Math' Name.Constant +'.' Operator +'sqrt' Name +'(' Punctuation +'d' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_2.16' Comment.Single +'\n' Text + +'number' Name +' ' Text +'=' Operator +' ' Text +'hexadecimal' Name +'.' Operator +'hex' Name +'\n' Text + +'number' Name +' ' Text +'=' Operator +' ' Text +'octal' Name +'.' Operator +'oct' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Gimme a number in decimal, octal, or hex: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'exit' Name.Builtin +' ' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'num' Name +')' Punctuation +'\n' Text + +'num' Name +' ' Text +'=' Operator +' ' Text +'num' Name +'.' Operator +'oct' Name +' ' Text +'if' Keyword +' ' Text +'num' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^0' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'# does both oct and hex ' Comment.Single +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'%d %x %o' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +',' Punctuation +' ' Text +'num' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Enter file permission in octal: ' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'permissions' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'raise' Keyword +' ' Text +'"' Literal.String.Double +'Exiting ...' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'unless' Keyword +' ' Text +'defined?' Name +'(' Punctuation +'permissions' Name +')' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'The decimal value is ' Literal.String.Double +'#{' Literal.String.Interpol +'permissions' Name +'.' Operator +'oct' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_2.17' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'commify' Name.Function +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'n' Name +'.' Operator +'to_s' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'([^' Literal.String.Regex +'\\' Literal.String.Regex +'.]*)(' Literal.String.Regex +'\\' Literal.String.Regex +'..*)?' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'int' Name +',' Punctuation +' ' Text +'dec' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +'.' Operator +'reverse' Name +',' Punctuation +' ' Text +'$2' Name.Variable.Global +' ' Text +'?' Punctuation +' ' Text +'$2' Name.Variable.Global +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'while' Keyword +' ' Text +'int' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'(,|' Literal.String.Regex +'\\' Literal.String.Regex +'.|^)(' Literal.String.Regex +'\\' Literal.String.Regex +'d{3})(' Literal.String.Regex +'\\' Literal.String.Regex +'d)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\1' Literal.String.Escape +'\\2' Literal.String.Escape +',' Literal.String.Single +'\\3' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'int' Name +'.' Operator +'reverse' Name +' ' Text +'+' Operator +' ' Text +'dec' Name +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_2.18' Comment.Single +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'It took %d hour%s' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'time' Name +',' Punctuation +' ' Text +'time' Name +' ' Text +'==' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +' ' Text +':' Punctuation +' ' Text +'"' Literal.String.Double +'s' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'# dunno if an equivalent to Lingua::EN::Inflect exists...' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_2.19' Comment.Single +'\n' Text + +'#-----------------------------' Comment.Single +'\n' Text + +'#!/usr/bin/ruby' Comment.Single +'\n' Text + +'# bigfact - calculating prime factors' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'factorize' Name.Function +'(' Punctuation +'orig' Name +')' Punctuation +'\n ' Text +'factors' Name +' ' Text +'=' Operator +' ' Text +'{' Punctuation +'}' Punctuation +'\n ' Text +'factors' Name +'.' Operator +'default' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'# return 0 instead nil if key not found in hash' Comment.Single +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'orig' Name +'\n ' Text +'i' Name +' ' Text +'=' Operator +' ' Text +'2' Literal.Number.Integer +'\n ' Text +'sqi' Name +' ' Text +'=' Operator +' ' Text +'4' Literal.Number.Integer +' ' Text +'# square of i' Comment.Single +'\n ' Text +'while' Keyword +' ' Text +'sqi' Name +' ' Text +'<' Operator +'=' Operator +' ' Text +'n' Name +' ' Text +'do' Keyword +'\n ' Text +'while' Keyword +' ' Text +'n' Name +'.' Operator +'modulo' Name +'(' Punctuation +'i' Name +')' Punctuation +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'do' Keyword +'\n ' Text +'n' Name +' ' Text +'/=' Operator +' ' Text +'i' Name +'\n ' Text +'factors' Name +'[' Operator +'i' Name +']' Operator +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'# puts "Found factor #{i}"' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'# we take advantage of the fact that (i +1)**2 = i**2 + 2*i +1' Comment.Single +'\n ' Text +'sqi' Name +' ' Text +'+=' Operator +' ' Text +'2' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'i' Name +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n \n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'n' Name +' ' Text +'!=' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'&&' Operator +' ' Text +'(' Punctuation +'n' Name +' ' Text +'!=' Operator +' ' Text +'orig' Name +')' Punctuation +'\n ' Text +'factors' Name +'[' Operator +'n' Name +']' Operator +' ' Text +'+=' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'end' Keyword +'\n ' Text +'factors' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'printfactorhash' Name.Function +'(' Punctuation +'orig' Name +',' Punctuation +' ' Text +'factorcount' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'format' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'%-10d ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'orig' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'factorcount' Name +'.' Operator +'length' Name +' ' Text +'==' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'PRIME' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'else' Keyword +'\n ' Text +'# sorts after number, because the hash keys are numbers' Comment.Single +'\n ' Text +'factorcount' Name +'.' Operator +'sort' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'factor' Name +',' Punctuation +'exponent' Name +'|' Operator +'\n ' Text +'print' Name.Builtin +' ' Text +'factor' Name +'\n ' Text +'if' Keyword +' ' Text +'exponent' Name +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'**' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'exponent' Name +'\n ' Text +'end' Keyword +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +' ' Literal.String.Double +'"' Literal.String.Double +'\n ' Text +'}' Punctuation +'\n ' Text +'end' Keyword +'\n ' Text +'puts' Name.Builtin +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'arg' Name +' ' Text +'in' Keyword +' ' Text +'ARGV' Name.Constant +'\n ' Text +'n' Name +' ' Text +'=' Operator +' ' Text +'arg' Name +'.' Operator +'to_i' Name +'\n ' Text +'mfactors' Name +' ' Text +'=' Operator +' ' Text +'factorize' Name +'(' Punctuation +'n' Name +')' Punctuation +'\n ' Text +'printfactorhash' Name +'(' Punctuation +'n' Name +',' Punctuation +' ' Text +'mfactors' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'#-----------------------------' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.0' Comment.Single +'\n' Text + +'puts' Name.Builtin +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Today is day ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'yday' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' of the current year.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Today is day ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'day' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' of the current month.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.1' Comment.Single +'\n' Text + +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'day' Name +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'month' Name +',' Punctuation +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'year' Name +'\n' Text + +'# or' Comment.Single +'\n' Text + +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'to_a' Name +'[' Operator +'3' Literal.Number.Integer +'..' Operator +'5' Literal.Number.Integer +']' Operator +'\n\n' Text + +'tl' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'localtime' Name +'\n' Text + +'printf' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'The current date is %04d %02d %02d' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'year' Name +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'month' Name +',' Punctuation +' ' Text +'tl' Name +'.' Operator +'day' Name +')' Punctuation +'\n\n' Text + +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'localtime' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%Y-%m-%d' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_3.2' Comment.Single +'\n' Text + +'Time' Name.Constant +'.' Operator +'local' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'minute' Name +',' Punctuation +' ' Text +'second' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n' Text + +'Time' Name.Constant +'.' Operator +'gm' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'minute' Name +',' Punctuation +' ' Text +'second' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.3' Comment.Single +'\n' Text + +'sec' Name +',' Punctuation +' ' Text +'min' Name +',' Punctuation +' ' Text +'hour' Name +',' Punctuation +' ' Text +'day' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'year' Name +',' Punctuation +' ' Text +'wday' Name +',' Punctuation +' ' Text +'yday' Name +',' Punctuation +' ' Text +'isdst' Name +',' Punctuation +' ' Text +'zone' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'epoch_secs' Name +')' Punctuation +'.' Operator +'to_a' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.4' Comment.Single +'\n' Text + +'when_' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'+' Operator +' ' Text +'difference' Name +' ' Text +'# now -> Time ; difference -> Numeric (delta in seconds)' Comment.Single +'\n' Text + +'then_' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'-' Operator +' ' Text +'difference' Name +'\n\n\n' Text + +'# @@PLEAC@@_3.5' Comment.Single +'\n' Text + +'bree' Name +' ' Text +'=' Operator +' ' Text +'361535725' Literal.Number.Integer +'\n' Text + +'nat' Name +' ' Text +'=' Operator +' ' Text +'96201950' Literal.Number.Integer +'\n\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'bree' Name +' ' Text +'-' Operator +' ' Text +'nat' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'There were ' Literal.String.Double +'#{' Literal.String.Interpol +'difference' Name +'}' Literal.String.Interpol +' seconds between Nat and Bree' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'seconds' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'seconds' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'minutes' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'minutes' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'60' Literal.Number.Integer +'\n' Text + +'hours' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'24' Literal.Number.Integer +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'hours' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'24' Literal.Number.Integer +'\n' Text + +'days' Name +' ' Text +'=' Operator +' ' Text +'difference' Name +' ' Text +'%' Operator +' ' Text +'7' Literal.Number.Integer +'\n' Text + +'weeks' Name +' ' Text +'=' Operator +' ' Text +'(' Punctuation +'difference' Name +' ' Text +'-' Operator +' ' Text +'days' Name +')' Punctuation +' ' Text +'/' Operator +' ' Text +'7' Literal.Number.Integer +'\n\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'(' Literal.String.Double +'#{' Literal.String.Interpol +'weeks' Name +'}' Literal.String.Interpol +' weeks, ' Literal.String.Double +'#{' Literal.String.Interpol +'days' Name +'}' Literal.String.Interpol +' days, ' Literal.String.Double +'#{' Literal.String.Interpol +'hours' Name +'}' Literal.String.Interpol +':' Literal.String.Double +'#{' Literal.String.Interpol +'minutes' Name +'}' Literal.String.Interpol +':' Literal.String.Double +'#{' Literal.String.Interpol +'seconds' Name +'}' Literal.String.Interpol +')' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.6' Comment.Single +'\n' Text + +'monthday' Name +',' Punctuation +' ' Text +'weekday' Name +',' Punctuation +' ' Text +'yearday' Name +' ' Text +'=' Operator +' ' Text +'date' Name +'.' Operator +'mday' Name +',' Punctuation +' ' Text +'date' Name +'.' Operator +'wday' Name +',' Punctuation +' ' Text +'date' Name +'.' Operator +'yday' Name +'\n\n' Text + +'# AFAIK the week number is not just a division since week boundaries are on sundays' Comment.Single +'\n' Text + +'weeknum' Name +' ' Text +'=' Operator +' ' Text +'d' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%U' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'to_i' Name +' ' Text +'+' Operator +' ' Text +'1' Literal.Number.Integer +'\n\n' Text + +'year' Name +' ' Text +'=' Operator +' ' Text +'1981' Literal.Number.Integer +'\n' Text + +'month' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'jun' Literal.String.Double +'"' Literal.String.Double +' ' Text +"# or `6' if you want to emulate a broken language" Comment.Single +'\n' Text + +'day' Name +' ' Text +'=' Operator +' ' Text +'16' Literal.Number.Integer +'\n' Text + +'t' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'year' Name +',' Punctuation +' ' Text +'month' Name +',' Punctuation +' ' Text +'day' Name +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'month' Name +'}' Literal.String.Interpol +'/' Literal.String.Double +'#{' Literal.String.Interpol +'day' Name +'}' Literal.String.Interpol +'/' Literal.String.Double +'#{' Literal.String.Interpol +'year' Name +'}' Literal.String.Interpol +' was a ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'t' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%A' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.7' Comment.Single +'\n' Text + +'yyyy' Name +',' Punctuation +' ' Text +'mm' Name +',' Punctuation +' ' Text +'dd' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +',' Punctuation +' ' Text +'$2' Name.Variable.Global +',' Punctuation +' ' Text +'$3' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'"' Literal.String.Double +'1998-06-25' Literal.String.Double +'"' Literal.String.Double +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)-(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)-(' Literal.String.Regex +'\\' Literal.String.Regex +'d+)' Literal.String.Regex +'/' Literal.String.Regex +'\n\n' Text + +'epoch_seconds' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'yyyy' Name +',' Punctuation +' ' Text +'mm' Name +',' Punctuation +' ' Text +'dd' Name +')' Punctuation +'.' Operator +'tv_sec' Name +'\n\n' Text + +'# dunno an equivalent to Date::Manip#ParseDate' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.8' Comment.Single +'\n' Text + +'string' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'epoch_secs' Name +')' Punctuation +'\n' Text + +'Time' Name.Constant +'.' Operator +'at' Name +'(' Punctuation +'1234567890' Literal.Number.Integer +')' Punctuation +'.' Operator +'gmtime' Name +' ' Text +'# gives: Fri Feb 13 23:31:30 UTC 2009' Comment.Single +'\n\n' Text + +'time' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'mktime' Name +'(' Punctuation +'1973' Literal.Number.Integer +',' Punctuation +' ' Text +'"' Literal.String.Double +'jan' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'18' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'45' Literal.Number.Integer +',' Punctuation +' ' Text +'50' Literal.Number.Integer +')' Punctuation +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'In localtime it gives: ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'time' Name +'.' Operator +'localtime' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_3.9' Comment.Single +'\n' Text + +'# Ruby provides micro-seconds in Time object' Comment.Single +'\n' Text + +'Time' Name.Constant +'.' Operator +'now' Name +'.' Operator +'usec' Name +'\n\n' Text + +'# Ruby gives the seconds in floating format when substracting two Time objects' Comment.Single +'\n' Text + +'before' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n' Text + +'line' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'\n' Text + +'elapsed' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +' ' Text +'-' Operator +' ' Text +'before' Name +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'You took ' Literal.String.Double +'#{' Literal.String.Interpol +'elapsed' Name +'}' Literal.String.Interpol +' seconds.' Literal.String.Double +'"' Literal.String.Double +'\n\n' Text + +'# On my Celeron-400 with Linux-2.2.19-14mdk, average for three execs are:' Comment.Single +'\n' Text + +'# This Ruby version: average 0.00321 sec' Comment.Single +'\n' Text + +"# Cookbook's Perl version: average 0.00981 sec" Comment.Single +'\n' Text + +'size' Name +' ' Text +'=' Operator +' ' Text +'500' Literal.Number.Integer +'\n' Text + +'number_of_times' Name +' ' Text +'=' Operator +' ' Text +'100' Literal.Number.Integer +'\n' Text + +'total_time' Name +' ' Text +'=' Operator +' ' Text +'0' Literal.Number.Integer +'\n' Text + +'number_of_times' Name +'.' Operator +'times' Name +' ' Text +'{' Punctuation +'\n ' Text +'# populate array' Comment.Single +'\n ' Text +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n ' Text +'size' Name +'.' Operator +'times' Name +' ' Text +'{' Punctuation +' ' Text +'array' Name +' ' Text +'<<' Operator +' ' Text +'rand' Name.Builtin +' ' Text +'}' Punctuation +'\n ' Text +'# sort it' Comment.Single +'\n ' Text +'begin_' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +'\n ' Text +'array' Name +'.' Operator +'sort!' Name +'\n ' Text +'time' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'now' Name +' ' Text +'-' Operator +' ' Text +'begin_' Name +'\n ' Text +'total_time' Name +' ' Text +'+=' Operator +' ' Text +'time' Name +'\n' Text + +'}' Punctuation +'\n' Text + +'printf' Name.Builtin +' ' Text +'"' Literal.String.Double +'On average, sorting %d random numbers takes %.5f seconds' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +',' Punctuation +'\n ' Text +'size' Name +',' Punctuation +' ' Text +'(' Punctuation +'total_time' Name +'/' Operator +'Float' Name.Builtin +'(' Punctuation +'number_of_times' Name +')' Punctuation +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_3.10' Comment.Single +'\n' Text + +'sleep' Name.Builtin +'(' Punctuation +'0' Literal.Number.Integer +'.' Operator +'005' Literal.Number.Oct +')' Punctuation +' ' Text +'# Ruby is definitely not as broken as Perl :)' Comment.Single +'\n' Text + +'# (may be interrupted by sending the process a SIGALRM)' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_3.11' Comment.Single +'\n' Text + +'#!/usr/bin/ruby -w' Comment.Single +'\n' Text + +'# hopdelta - feed mail header, produce lines' Comment.Single +'\n' Text + +'# showing delay at each hop.' Comment.Single +'\n' Text + +'require' Name.Builtin +' ' Text +"'" Literal.String.Single +'time' Literal.String.Single +"'" Literal.String.Single +'\n' Text + +'class' Keyword +' ' Text +'MailHopDelta' Name.Class +'\n\n ' Text +'def' Keyword +' ' Text +'initialize' Name.Function +'(' Punctuation +'mail' Name +')' Punctuation +'\n ' Text +'@head' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'mail' Name +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'\\' Literal.String.Regex +'s+' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'@topline' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'%w-Sender Recipient Time Delta-' Literal.String.Other +'\n ' Text +'@start_from' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'mail' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^From.*' Literal.String.Regex +'\\' Literal.String.Regex +'@([^' Literal.String.Regex +'\\' Literal.String.Regex +'s>]*)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'@date' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'parse' Name +'(' Punctuation +'mail' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +'^Date:' Literal.String.Regex +'\\' Literal.String.Regex +'s+(.*)' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'out' Name.Function +'(' Punctuation +'line' Name +')' Punctuation +'\n ' Text +'"' Literal.String.Double +'%-20.20s %-20.20s %-20.20s %s' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'line' Name +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'hop_date' Name.Function +'(' Punctuation +'day' Name +')' Punctuation +'\n ' Text +'day' Name +'.' Operator +'strftime' Name +'(' Punctuation +'"' Literal.String.Double +'%I:%M:%S %Y/%m/%d' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'puts_hops' Name.Function +'\n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'@topline' Name.Variable.Instance +')' Punctuation +' \n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'[' Operator +"'" Literal.String.Single +'Start' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'@start_from' Name.Variable.Instance +',' Punctuation +' ' Text +'hop_date' Name +'(' Punctuation +'@date' Name.Variable.Instance +')' Punctuation +',' Punctuation +"'" Literal.String.Single +"'" Literal.String.Single +']' Operator +')' Punctuation +'\n ' Text +'@head' Name.Variable.Instance +'.' Operator +'split' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'n' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'reverse' Name +'.' Operator +'grep' Name +'(' Punctuation +'/' Literal.String.Regex +'^Received:' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'.' Operator +'each' Name +' ' Text +'do' Keyword +' ' Text +'|' Operator +'hop' Name +'|' Operator +'\n ' Text +'hop' Name +'.' Operator +'gsub!' Name +'(' Punctuation +'/' Literal.String.Regex +'\\' Literal.String.Regex +'bon (.*?) (id.*)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +"'" Literal.String.Single +'; ' Literal.String.Single +'\\1' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'whence' Name +' ' Text +'=' Operator +' ' Text +'hop' Name +'.' Operator +'match' Name +'(' Punctuation +'/' Literal.String.Regex +';' Literal.String.Regex +'\\' Literal.String.Regex +'s+(.*)$' Literal.String.Regex +'/' Literal.String.Regex +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'unless' Keyword +' ' Text +'whence' Name +'\n ' Text +'warn' Name.Builtin +' ' Text +'"' Literal.String.Double +'Bad received line: ' Literal.String.Double +'#{' Literal.String.Interpol +'hop' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'next' Keyword +'\n ' Text +'end' Keyword +'\n ' Text +'from' Name +' ' Text +'=' Operator +' ' Text +'$+' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'hop' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'from' Literal.String.Regex +'\\' Literal.String.Regex +'s+(' Literal.String.Regex +'\\' Literal.String.Regex +'S+)|' Literal.String.Regex +'\\' Literal.String.Regex +'((.*?)' Literal.String.Regex +'\\' Literal.String.Regex +')' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'by' Name +' ' Text +'=' Operator +' ' Text +'$1' Name.Variable.Global +' ' Text +'if' Keyword +' ' Text +'hop' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'by' Literal.String.Regex +'\\' Literal.String.Regex +'s+(' Literal.String.Regex +'\\' Literal.String.Regex +'S+' Literal.String.Regex +'\\' Literal.String.Regex +'.' Literal.String.Regex +'\\' Literal.String.Regex +'S+)' Literal.String.Regex +'/' Literal.String.Regex +'\n ' Text +'next' Keyword +' ' Text +'unless' Keyword +' ' Text +'now' Name +' ' Text +'=' Operator +' ' Text +'Time' Name.Constant +'.' Operator +'parse' Name +'(' Punctuation +'whence' Name +')' Punctuation +'.' Operator +'localtime' Name +'\n ' Text +'delta' Name +' ' Text +'=' Operator +' ' Text +'now' Name +' ' Text +'-' Operator +' ' Text +'@date' Name.Variable.Instance +'\n ' Text +'puts' Name.Builtin +' ' Text +'out' Name +'(' Punctuation +'[' Operator +'from' Name +',' Punctuation +' ' Text +'by' Name +',' Punctuation +' ' Text +'hop_date' Name +'(' Punctuation +'now' Name +')' Punctuation +',' Punctuation +' ' Text +'hop_time' Name +'(' Punctuation +'delta' Name +')' Punctuation +']' Operator +')' Punctuation +'\n ' Text +'@date' Name.Variable.Instance +' ' Text +'=' Operator +' ' Text +'now' Name +'\n ' Text +'end' Keyword +'\n ' Text +'end' Keyword +'\n\n ' Text +'def' Keyword +' ' Text +'hop_time' Name.Function +'(' Punctuation +'secs' Name +')' Punctuation +'\n ' Text +'sign' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +' ' Text +'<' Operator +' ' Text +'0' Literal.Number.Integer +' ' Text +'?' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +' ' Text +':' Punctuation +' ' Text +'1' Literal.Number.Integer +'\n ' Text +'days' Name +',' Punctuation +' ' Text +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'24' Literal.Number.Integer +')' Punctuation +'\n ' Text +'hours' Name +',' Punctuation +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +' ' Text +'*' Operator +' ' Text +'60' Literal.Number.Integer +')' Punctuation +'\n ' Text +'mins' Name +',' Punctuation +' ' Text +'secs' Name +' ' Text +'=' Operator +' ' Text +'secs' Name +'.' Operator +'abs' Name +'.' Operator +'divmod' Name +'(' Punctuation +'60' Literal.Number.Integer +')' Punctuation +'\n ' Text +'rtn' Name +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'%3ds' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'secs' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dm' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'mins' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'mins' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dh' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'hours' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'hours' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +'\n ' Text +'rtn' Name +' ' Text +'<<' Operator +' ' Text +'"' Literal.String.Double +'%3dd' Literal.String.Double +'"' Literal.String.Double +' ' Text +'%' Operator +' ' Text +'[' Operator +'days' Name +' ' Text +'*' Operator +' ' Text +'sign' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'days' Name +' ' Text +'!=' Operator +' ' Text +'0' Literal.Number.Integer +' \n ' Text +'rtn' Name +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'$/' Name.Variable.Global +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'mail' Name +' ' Text +'=' Operator +' ' Text +'MailHopDelta' Name.Constant +'.' Operator +'new' Name +'(' Punctuation +'ARGF' Name.Constant +'.' Operator +'gets' Name +')' Punctuation +'.' Operator +'puts_hops' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.0' Comment.Single +'\n' Text + +'single_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n\n' Text + +'# Ruby directly supports nested arrays' Comment.Single +'\n' Text + +'double_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +' ' Text +']' Operator +'\n' Text + +'still_single_level' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'this' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'that' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'the' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'other' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +' ' Text +']' Operator +'.' Operator +'flatten' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.1' Comment.Single +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'quick' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'brown' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'fox' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Why are you teasing me?' Literal.String.Other +')' Literal.String.Other +'\n\n' Text + +'lines' Name +' ' Text +'=' Operator +' ' Text +'<<' Operator +'"' Literal.String.Heredoc +'END_OF_HERE_DOC' Literal.String.Delimiter +'"' Literal.String.Heredoc +'.' Operator +'gsub' Name +'(' Punctuation +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'s*(.+)' Literal.String.Regex +'/' Literal.String.Regex +',' Punctuation +' ' Text +"'" Literal.String.Single +'\\1' Literal.String.Escape +"'" Literal.String.Single +')' Punctuation +'\n' Text + +' The boy stood on the burning deck,\n' Literal.String.Heredoc + +' It was as hot as glass.\n' Literal.String.Heredoc + +'END_OF_HERE_DOC\n' Literal.String.Delimiter + +'\n' Text + +'bigarray' Name +' ' Text +'=' Operator +' ' Text +'IO' Name.Constant +'.' Operator +'readlines' Name +'(' Punctuation +'"' Literal.String.Double +'mydatafile' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'l' Name +'|' Operator +' ' Text +'l' Name +'.' Operator +'chomp' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'name' Name.Builtin +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Gandalf' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'banner' Name +' ' Text +'=' Operator +' ' Text +'%Q(' Literal.String.Other +'Speak, ' Literal.String.Other +'#{' Literal.String.Interpol +'name' Name.Builtin +'}' Literal.String.Interpol +', and welcome!' Literal.String.Other +')' Literal.String.Other +'\n\n' Text + +'host_info' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'host ' Literal.String.Backtick +'#{' Literal.String.Interpol +'his_host' Name +'}' Literal.String.Interpol +'`' Literal.String.Backtick +'\n\n' Text + +'%x(' Literal.String.Other +'ps ' Literal.String.Other +'#{' Literal.String.Interpol +'$$' Name.Variable.Global +'}' Literal.String.Interpol +')' Literal.String.Other +'\n\n' Text + +'banner' Name +' ' Text +'=' Operator +' ' Text +"'" Literal.String.Single +'Costs only $4.95' Literal.String.Single +"'" Literal.String.Single +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n\n' Text + +'rax' Name +' ' Text +'=' Operator +' ' Text +'%w! ( ) < > { } [ ] !' Literal.String.Other +'\n\n\n' Text + +'# @@PLEAC@@_4.2' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'commify_series' Name.Function +'(' Punctuation +'arr' Name +')' Punctuation +'\n ' Text +'return' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'arr' Name +'\n ' Text +'case' Keyword +' ' Text +'arr' Name +'.' Operator +'size' Name +'\n ' Text +'when' Keyword +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'when' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n ' Text +'when' Keyword +' ' Text +'2' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' and ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'else' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +'..' Operator +'-' Operator +'2' Literal.Number.Integer +']' Operator +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +', ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +', and ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'arr' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'array' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'red' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'yellow' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'green' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'array' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have redyellowgreen marbles' Comment.Single +'\n\n' Text + +'# But unlike Perl:' Comment.Single +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'array' Name +'}' Literal.String.Interpol +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have redyellowgreen marbles' Comment.Single +'\n' Text + +'# So, needs:' Comment.Single +'\n' Text + +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'I have ' Literal.String.Double +'#{' Literal.String.Interpol +'array' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +' marbles' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'# -> I have red yellow green marbles' Comment.Single +'\n\n' Text + +'#!/usr/bin/ruby' Comment.Single +'\n' Text + +'# communify_series - show proper comma insertion in list output' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'commify_series' Name.Function +'(' Punctuation +'arr' Name +')' Punctuation +'\n ' Text +'return' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +' ' Text +'if' Keyword +' ' Text +'not' Operator.Word +' ' Text +'arr' Name +'\n ' Text +'sepchar' Name +' ' Text +'=' Operator +' ' Text +'arr' Name +'.' Operator +'find' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'p' Name.Builtin +'|' Operator +' ' Text +'p' Name.Builtin +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +',' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'}' Punctuation +' ' Text +'?' Punctuation +' ' Text +"'" Literal.String.Single +'; ' Literal.String.Single +"'" Literal.String.Single +' ' Text +':' Punctuation +' ' Text +"'" Literal.String.Single +', ' Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'case' Keyword +' ' Text +'arr' Name +'.' Operator +'size' Name +'\n ' Text +'when' Keyword +' ' Text +'0' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +"'" Literal.String.Single +"'" Literal.String.Single +'\n ' Text +'when' Keyword +' ' Text +'1' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n ' Text +'when' Keyword +' ' Text +'2' Literal.Number.Integer +' ' Text +'then' Keyword +' ' Text +'arr' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' and ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'\n ' Text +'else' Keyword +' ' Text +'arr' Name +'[' Operator +'0' Literal.Number.Integer +'..' Operator +'-' Operator +'2' Literal.Number.Integer +']' Operator +'.' Operator +'join' Name +'(' Punctuation +'sepchar' Name +')' Punctuation +' ' Text +'+' Operator +' ' Text +'sepchar' Name +' ' Text +'+' Operator +' ' Text +"'" Literal.String.Single +'and ' Literal.String.Single +"'" Literal.String.Single +' ' Text +'+' Operator +' ' Text +'arr' Name +'[' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'lists' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'just one thing' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'%w(' Literal.String.Other +'Mutt Jeff' Literal.String.Other +')' Literal.String.Other +',' Punctuation +'\n ' Text +'%w(' Literal.String.Other +'Peter Paul Mary' Literal.String.Other +')' Literal.String.Other +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'To our parents' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'Mother Theresa' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'God' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'pastrami' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ham and cheese' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'peanut butter and jelly' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'tuna' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'recycle tired, old phrases' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +"'" Literal.String.Single +'ponder big, happy thoughts' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n ' Text +'[' Operator +' ' Text +"'" Literal.String.Single +'recycle tired, old phrases' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n ' Text +"'" Literal.String.Single +'ponder big, happy thoughts' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +'\n ' Text +"'" Literal.String.Single +'sleep and dream peacefully' Literal.String.Single +"'" Literal.String.Single +' ' Text +']' Operator +',' Punctuation +'\n' Text + +']' Operator +'\n\n' Text + +'for' Keyword +' ' Text +'list' Name +' ' Text +'in' Keyword +' ' Text +'lists' Name +' ' Text +'do' Keyword +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'The list is: ' Literal.String.Double +'#{' Literal.String.Interpol +'commify_series' Name +'(' Punctuation +'list' Name +')' Punctuation +'}' Literal.String.Interpol +'.' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.3' Comment.Single +'\n' Text + +"# (note: AFAIK Ruby doesn't allow gory change of Array length)" Comment.Single +'\n' Text + +'# grow the array by assigning nil to past the end of array' Comment.Single +'\n' Text + +'ary' Name +'[' Operator +'new_size' Name +'-' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'nil' Keyword.Pseudo +'\n' Text + +'# shrink the array by slicing it down' Comment.Single +'\n' Text + +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'new_size' Name +'..' Operator +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n' Text + +'# init the array with given size' Comment.Single +'\n' Text + +'Array' Name.Builtin +'.' Operator +'new' Name +'(' Punctuation +'number_of_elems' Name +')' Punctuation +'\n' Text + +'# assign to an element past the original end enlarges the array' Comment.Single +'\n' Text + +'ary' Name +'[' Operator +'index_new_last_elem' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'value' Name +'\n\n' Text + +'def' Keyword +' ' Text +'what_about_that_array' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'The array now has ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'a' Name +'.' Operator +'size' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' elements.' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n ' Text +'# Index of last element is not really interesting in Ruby' Comment.Single +'\n ' Text +'print' Name.Builtin +' ' Text +'"' Literal.String.Double +'Element ' Literal.String.Double +'#' Literal.String.Double +'3 is `' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +'}' Literal.String.Interpol +"'." Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n' Text + +'people' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Crosby Stills Nash Young' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'what_about_that_array' Name +'(' Punctuation +'people' Name +')' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.4' Comment.Single +'\n' Text + +'# OO style' Comment.Single +'\n' Text + +'bad_users' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'user' Name +'|' Operator +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n' Text + +'}' Punctuation +'\n' Text + +'# or, functional style' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'bad_users' Name +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'var' Name +' ' Text +'in' Keyword +' ' Text +'ENV' Name.Constant +'.' Operator +'keys' Name +'.' Operator +'sort' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'var' Name +'}' Literal.String.Interpol +'=' Literal.String.Double +'#{' Literal.String.Interpol +'ENV' Name.Constant +'[' Operator +'var' Name +']' Operator +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'all_users' Name +'\n ' Text +'disk_space' Name +' ' Text +'=' Operator +' ' Text +'get_usage' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n ' Text +'if' Keyword +' ' Text +'(' Punctuation +'disk_space' Name +' ' Text +'>' Operator +' ' Text +'MAX_QUOTA' Name.Constant +')' Punctuation +'\n ' Text +'complain' Name +'(' Punctuation +'user' Name +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'IO' Name.Constant +'.' Operator +'popen' Name +'(' Punctuation +'"' Literal.String.Double +'who' Literal.String.Double +'"' Literal.String.Double +')' Punctuation +'.' Operator +'readlines' Name +'\n ' Text +'print' Name.Builtin +' ' Text +'l' Name +' ' Text +'if' Keyword +' ' Text +'l' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^gc' Literal.String.Regex +'/' Literal.String.Regex +' \n' Text + +'end' Keyword +'\n\n' Text + +'# we can mimic the obfuscated Perl way' Comment.Single +'\n' Text + +'while' Keyword +' ' Text +'fh' Name +'.' Operator +'gets' Name +' ' Text +'# $_ is set to the line just read' Comment.Single +'\n ' Text +'chomp' Name.Builtin +' ' Text +'# $_ has a trailing \\n removed, if it had one' Comment.Single +'\n ' Text +'split' Name.Builtin +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'# $_ is split on whitespace' Comment.Single +'\n ' Text +'# but $_ is not set to each chunk as in Perl' Comment.Single +'\n ' Text +'print' Name.Builtin +' ' Text +'w' Name +'.' Operator +'reverse' Name +'\n ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'# ...or use a cleaner way' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'l' Name +' ' Text +'in' Keyword +' ' Text +'fh' Name +'.' Operator +'readlines' Name +'\n ' Text +'l' Name +'.' Operator +'chomp' Name +'.' Operator +'split' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'w' Name +'|' Operator +' ' Text +'print' Name.Builtin +' ' Text +'w' Name +'.' Operator +'reverse' Name +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +"# same drawback as in problem 1.4, we can't mutate a Numeric..." Comment.Single +'\n' Text + +'array' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +' ' Text +'-' Operator +' ' Text +'1' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n\n' Text + +'a' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'.' Operator +'5' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +' ' Text +']' Operator +';' Punctuation +' ' Text +'b' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +' ' Text +']' Operator +'\n' Text + +'for' Keyword +' ' Text +'ary' Name +' ' Text +'in' Keyword +' ' Text +'[' Operator +' ' Text +'a' Name +',' Punctuation +' ' Text +'b' Name +' ' Text +']' Operator +'\n ' Text +'ary' Name +'.' Operator +'collect!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +' ' Text +'*' Operator +' ' Text +'7' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'#{' Literal.String.Interpol +'a' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +' ' Literal.String.Double +'#{' Literal.String.Interpol +'b' Name +'.' Operator +'join' Name +'(' Punctuation +"'" Literal.String.Single +' ' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n\n' Text + +'# we can mutate Strings, cool; we need a trick for the scalar' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'ary' Name +' ' Text +'in' Keyword +' ' Text +'[' Operator +' ' Text +'[' Operator +' ' Text +'scalar' Name +' ' Text +']' Operator +',' Punctuation +' ' Text +'array' Name +',' Punctuation +' ' Text +'hash' Name.Builtin +'.' Operator +'values' Name +' ' Text +']' Operator +'\n ' Text +'ary' Name +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'v' Name +'|' Operator +' ' Text +'v' Name +'.' Operator +'strip!' Name +' ' Text +'}' Punctuation +' ' Text +'# String#strip rules :)' Comment.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.5' Comment.Single +'\n' Text + +'# not relevant in Ruby since we have always references' Comment.Single +'\n' Text + +'for' Keyword +' ' Text +'item' Name +' ' Text +'in' Keyword +' ' Text +'array' Name +'\n ' Text +'# do somethingh with item' Comment.Single +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.6' Comment.Single +'\n' Text + +'unique' Name +' ' Text +'=' Operator +' ' Text +'list' Name +'.' Operator +'uniq' Name +'\n\n' Text + +'# generate a list of users logged in, removing duplicates' Comment.Single +'\n' Text + +'users' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'who' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'l' Name +'|' Operator +' ' Text +'l' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'(' Literal.String.Regex +'\\' Literal.String.Regex +'w+)' Literal.String.Regex +'/' Literal.String.Regex +';' Punctuation +' ' Text +'$1' Name.Variable.Global +' ' Text +'}' Punctuation +'.' Operator +'sort' Name +'.' Operator +'uniq' Name +'\n' Text + +'puts' Name.Builtin +'(' Punctuation +'"' Literal.String.Double +'users logged in: ' Literal.String.Double +'#{' Literal.String.Interpol +'commify_series' Name +'(' Punctuation +'users' Name +')' Punctuation +'}' Literal.String.Interpol +'"' Literal.String.Double +')' Punctuation +' ' Text +'# see 4.2 for commify_series' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_4.7' Comment.Single +'\n' Text + +'a' Name +' ' Text +'-' Operator +' ' Text +'b' Name +'\n' Text + +'# [ 1, 1, 2, 2, 3, 3, 3, 4, 5 ] - [ 1, 2, 4 ] -> [3, 5]' Comment.Single +'\n\n\n' Text + +'# @@PLEAC@@_4.8' Comment.Single +'\n' Text + +'union' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'|' Operator +' ' Text +'b' Name +'\n' Text + +'intersection' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'&' Operator +' ' Text +'b' Name +'\n' Text + +'difference' Name +' ' Text +'=' Operator +' ' Text +'a' Name +' ' Text +'-' Operator +' ' Text +'b' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.9' Comment.Single +'\n' Text + +'array1' Name +'.' Operator +'concat' Name +'(' Punctuation +'array2' Name +')' Punctuation +'\n' Text + +'# if you will assign to another object, better use:' Comment.Single +'\n' Text + +'new_ary' Name +' ' Text +'=' Operator +' ' Text +'array1' Name +' ' Text +'+' Operator +' ' Text +'array2' Name +'\n\n' Text + +'members' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Time' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Flies' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'initiates' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'An' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Arrow' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'members' Name +' ' Text +'+=' Operator +' ' Text +'initiates' Name +'\n\n' Text + +'members' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Time' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Flies' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'initiates' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'An' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Arrow' Literal.String.Double +'"' Literal.String.Double +' ' Text +']' Operator +'\n' Text + +'members' Name +'[' Operator +'2' Literal.Number.Integer +',' Punctuation +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'[' Operator +' ' Text +'"' Literal.String.Double +'Like' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'initiates' Name +' ' Text +']' Operator +'.' Operator +'flatten' Name +'\n\n' Text + +'members' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'Fruit' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'members' Name +'[' Operator +'3' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +']' Operator +' ' Text +'=' Operator +' ' Text +'"' Literal.String.Double +'A' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'"' Literal.String.Double +'Banana' Literal.String.Double +'"' Literal.String.Double +'\n\n\n' Text + +'# @@PLEAC@@_4.10' Comment.Single +'\n' Text + +'reversed' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'reverse' Name +'\n\n' Text + +'ary' Name +'.' Operator +'reverse_each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +'\n ' Text +'# do something with e' Comment.Single +'\n' Text + +'}' Punctuation +'\n\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'sort' Name +'.' Operator +'reverse' Name +'\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'b' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.11' Comment.Single +'\n' Text + +'# remove n elements from front of ary (shift n)' Comment.Single +'\n' Text + +'front' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +',' Punctuation +' ' Text +'n' Name +')' Punctuation +'\n\n' Text + +'# remove n elements from the end of ary (pop n)' Comment.Single +'\n' Text + +'end_' Name +' ' Text +'=' Operator +' ' Text +'ary' Name +'.' Operator +'slice!' Name +'(' Punctuation +'-' Operator +'n' Name +' ' Text +'..' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n\n' Text + +"# let's extend the Array class, to make that useful" Comment.Single +'\n' Text + +'class' Keyword +' ' Text +'Array' Name.Class +'\n ' Text +'def' Keyword +' ' Text +'shift2' Name.Function +'(' Punctuation +')' Punctuation +'\n ' Text +'slice!' Name +'(' Punctuation +'0' Literal.Number.Integer +' ' Text +'..' Operator +' ' Text +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'# more symetric with pop2...' Comment.Single +'\n ' Text +'end' Keyword +'\n ' Text +'def' Keyword +' ' Text +'pop2' Name.Function +'(' Punctuation +')' Punctuation +'\n ' Text +'slice!' Name +'(' Punctuation +'-' Operator +'2' Literal.Number.Integer +' ' Text +'..' Operator +' ' Text +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n\n' Text + +'friends' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Peter Paul Mary Jim Tim' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'this' Name +',' Punctuation +' ' Text +'that' Name +' ' Text +'=' Operator +' ' Text +'friends' Name +'.' Operator +'shift2' Name +'\n\n' Text + +'beverages' Name +' ' Text +'=' Operator +' ' Text +'%w(' Literal.String.Other +'Dew Jolt Cola Sprite Fresca' Literal.String.Other +')' Literal.String.Other +'\n' Text + +'pair' Name +' ' Text +'=' Operator +' ' Text +'beverages' Name +'.' Operator +'pop2' Name +'\n\n\n' Text + +'# @@PLEAC@@_4.12' Comment.Single +'\n' Text + +'# use Enumerable#detect (or the synonym Enumerable#find)' Comment.Single +'\n' Text + +'highest_eng' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'detect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'emp' Name +'|' Operator +' ' Text +'emp' Name +'.' Operator +'category' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'engineer' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.13' Comment.Single +'\n' Text + +'# use Enumerable#select (or the synonym Enumerable#find_all)' Comment.Single +'\n' Text + +'bigs' Name +' ' Text +'=' Operator +' ' Text +'nums' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +' ' Text +'>' Operator +' ' Text +'1_000_000' Literal.Number.Integer +' ' Text +'}' Punctuation +'\n' Text + +'pigs' Name +' ' Text +'=' Operator +' ' Text +'users' Name +'.' Operator +'keys' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'k' Name +'|' Operator +' ' Text +'users' Name +'[' Operator +'k' Name +']' Operator +' ' Text +'>' Operator +' ' Text +'1' Literal.Number.Integer +'e7' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'matching' Name +' ' Text +'=' Operator +' ' Text +'`' Literal.String.Backtick +'who' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'u' Name +'|' Operator +' ' Text +'u' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^gnat ' Literal.String.Regex +'/' Literal.String.Regex +' ' Text +'}' Punctuation +'\n\n' Text + +'engineers' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'.' Operator +'position' Name +' ' Text +'==' Operator +' ' Text +"'" Literal.String.Single +'Engineer' Literal.String.Single +"'" Literal.String.Single +' ' Text +'}' Punctuation +'\n\n' Text + +'secondary_assistance' Name +' ' Text +'=' Operator +' ' Text +'applicants' Name +'.' Operator +'select' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +'|' Operator +'\n ' Text +'a' Name +'.' Operator +'income' Name +' ' Text +'>' Operator +'=' Operator +' ' Text +'26_000' Literal.Number.Integer +' ' Text +'&&' Operator +' ' Text +'a' Name +'.' Operator +'income' Name +' ' Text +'<' Operator +' ' Text +'30_000' Literal.Number.Integer +'\n' Text + +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.14' Comment.Single +'\n' Text + +'# normally you would have an array of Numeric (Float or' Comment.Single +'\n' Text + +'# Fixnum or Bignum), so you would use:' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +'\n' Text + +'# if you have strings representing Integers or Floats' Comment.Single +'\n' Text + +'# you may specify another sort method:' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'to_f' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'to_f' Name +' ' Text +'}' Punctuation +'\n\n' Text + +"# let's use the list of my own PID's" Comment.Single +'\n' Text + +'`' Literal.String.Backtick +'ps ux' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'split' Name +'(' Punctuation +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +')' Punctuation +'[' Operator +'1' Literal.Number.Integer +'..' Operator +'-' Operator +'1' Literal.Number.Integer +']' Operator +'.' Operator +'\n ' Text +'select' Name.Builtin +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^' Literal.String.Regex +'#{' Literal.String.Interpol +'ENV' Name.Constant +'[' Operator +"'" Literal.String.Single +'USER' Literal.String.Single +"'" Literal.String.Single +']' Operator +'}' Literal.String.Interpol +'/' Literal.String.Regex +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'i' Name +'.' Operator +'split' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'to_i' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'to_i' Name +' ' Text +'}' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +' ' Text +'puts' Name.Builtin +' ' Text +'i' Name +' ' Text +'}' Punctuation +'\n' Text + +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Select a process ID to kill:' Literal.String.Double +'"' Literal.String.Double +'\n' Text + +'pid' Name +' ' Text +'=' Operator +' ' Text +'gets' Name.Builtin +'.' Operator +'chomp' Name +'\n' Text + +'raise' Keyword +' ' Text +'"' Literal.String.Double +'Exiting ... ' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +' ' Text +'unless' Keyword +' ' Text +'pid' Name +' ' Text +'&&' Operator +' ' Text +'pid' Name +' ' Text +'=~' Operator +' ' Text +'/' Literal.String.Regex +'^' Literal.String.Regex +'\\' Literal.String.Regex +'d+$' Literal.String.Regex +'/' Literal.String.Regex +'\n' Text + +'Process' Name.Constant +'.' Operator +'kill' Name +'(' Punctuation +"'" Literal.String.Single +'TERM' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'pid' Name +'.' Operator +'to_i' Name +')' Punctuation +'\n' Text + +'sleep' Name.Builtin +' ' Text +'2' Literal.Number.Integer +'\n' Text + +'Process' Name.Constant +'.' Operator +'kill' Name +'(' Punctuation +"'" Literal.String.Single +'KILL' Literal.String.Single +"'" Literal.String.Single +',' Punctuation +' ' Text +'pid' Name +'.' Operator +'to_i' Name +')' Punctuation +'\n\n' Text + +'descending' Name +' ' Text +'=' Operator +' ' Text +'unsorted' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'b' Name +'.' Operator +'to_f' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +'.' Operator +'to_f' Name +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.15' Comment.Single +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'compare' Name +'(' Punctuation +'a' Name +',' Punctuation +'b' Name +')' Punctuation +' ' Text +'}' Punctuation +'\n\n' Text + +'precomputed' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'compute' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'ordered_precomputed' Name +' ' Text +'=' Operator +' ' Text +'precomputed' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'ordered_precomputed' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'unordered' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'compute' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'for' Keyword +' ' Text +'employee' Name +' ' Text +'in' Keyword +' ' Text +'employees' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'name' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'name' Name +' ' Text +'}' Punctuation +'\n ' Text +'print' Name.Builtin +' ' Text +'employee' Name +'.' Operator +'name' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +' earns ' Literal.String.Double +'\\' Literal.String.Double +'$ ' Literal.String.Double +'"' Literal.String.Double +',' Punctuation +' ' Text +'employee' Name +'.' Operator +'salary' Name +',' Punctuation +' ' Text +'"' Literal.String.Double +'\\n' Literal.String.Escape +'"' Literal.String.Double +'\n' Text + +'end' Keyword +'\n\n' Text + +"# Beware! `0' is true in Ruby." Comment.Single +'\n' Text + +'# For chaining comparisons, you may use Numeric#nonzero?, which' Comment.Single +'\n' Text + +'# returns num if num is not zero, nil otherwise' Comment.Single +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'employees' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'(' Punctuation +'a' Name +'.' Operator +'name' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'name' Name +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'b' Name +'.' Operator +'age' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'a' Name +'.' Operator +'age' Name +' ' Text +'}' Punctuation +'\n\n' Text + +'users' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +']' Operator +'\n' Text + +"# getpwent is not wrapped in Ruby... let's fallback" Comment.Single +'\n' Text + +'IO' Name.Constant +'.' Operator +'readlines' Name +'(' Punctuation +"'" Literal.String.Single +'/etc/passwd' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'each' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'u' Name +'|' Operator +' ' Text +'users' Name +' ' Text +'<<' Operator +' ' Text +'u' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +':' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +' ' Text +'}' Punctuation +'\n' Text + +'users' Name +'.' Operator +'sort!' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'for' Keyword +' ' Text +'user' Name +' ' Text +'in' Keyword +' ' Text +'users' Name +'\n ' Text +'puts' Name.Builtin +' ' Text +'user' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +'\n' Text + +'end' Keyword +'\n\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'names' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n' Text + +'sorted' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'.' Operator +'length' Name +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'.' Operator +'length' Name +' ' Text +'}' Punctuation +'\n\n' Text + +"# let's show only the compact version" Comment.Single +'\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'e' Name +'.' Operator +'length' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'ordered' Name +' ' Text +'=' Operator +' ' Text +'strings' Name +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'/' Literal.String.Regex +'\\' Literal.String.Regex +'d+' Literal.String.Regex +'/' Literal.String.Regex +'.' Operator +'match' Name +'(' Punctuation +'e' Name +')' Punctuation +'[' Operator +'0' Literal.Number.Integer +']' Operator +'.' Operator +'to_i' Name +',' Punctuation +' ' Text +'e' Name +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'a' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n' Text + +'print' Name.Builtin +' ' Text +'`' Literal.String.Backtick +'cat /etc/passwd' Literal.String.Backtick +'`' Literal.String.Backtick +'.' Operator +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'[' Operator +'e' Name +',' Punctuation +' ' Text +'e' Name +'.' Operator +'split' Name +'(' Punctuation +"'" Literal.String.Single +':' Literal.String.Single +"'" Literal.String.Single +')' Punctuation +'.' Operator +'indexes' Name +'(' Punctuation +'3' Literal.Number.Integer +',' Punctuation +'2' Literal.Number.Integer +',' Punctuation +'0' Literal.Number.Integer +')' Punctuation +']' Operator +'.' Operator +'flatten' Name +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'sort' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'a' Name +',' Punctuation +'b' Name +'|' Operator +' ' Text +'(' Punctuation +'a' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'1' Literal.Number.Integer +']' Operator +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'(' Punctuation +'a' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'2' Literal.Number.Integer +']' Operator +')' Punctuation +'.' Operator +'nonzero?' Name +' ' Text +'||' Operator +' ' Text +'a' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +' ' Text +'<' Operator +'=' Operator +'>' Operator +' ' Text +'b' Name +'[' Operator +'3' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'.' Operator +'\n ' Text +'collect' Name +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'e' Name +'|' Operator +' ' Text +'e' Name +'[' Operator +'0' Literal.Number.Integer +']' Operator +' ' Text +'}' Punctuation +'\n\n\n' Text + +'# @@PLEAC@@_4.16' Comment.Single +'\n' Text + +'circular' Name +'.' Operator +'unshift' Name +'(' Punctuation +'circular' Name +'.' Operator +'pop' Name +')' Punctuation +' ' Text +'# the last shall be first' Comment.Single +'\n' Text + +'circular' Name +'.' Operator +'push' Name +'(' Punctuation +'circular' Name +'.' Operator +'shift' Name +')' Punctuation +' ' Text +'# and vice versa' Comment.Single +'\n\n' Text + +'def' Keyword +' ' Text +'grab_and_rotate' Name.Function +'(' Punctuation +'l' Name +')' Punctuation +'\n ' Text +'l' Name +'.' Operator +'push' Name +'(' Punctuation +'ret' Name +' ' Text +'=' Operator +' ' Text +'l' Name +'.' Operator +'shift' Name +')' Punctuation +'\n ' Text +'ret' Name +'\n' Text + +'end' Keyword +'\n\n' Text + +'processes' Name +' ' Text +'=' Operator +' ' Text +'[' Operator +'1' Literal.Number.Integer +',' Punctuation +' ' Text +'2' Literal.Number.Integer +',' Punctuation +' ' Text +'3' Literal.Number.Integer +',' Punctuation +' ' Text +'4' Literal.Number.Integer +',' Punctuation +' ' Text +'5' Literal.Number.Integer +']' Operator +'\n' Text + +'while' Keyword +' ' Text +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'process' Name +' ' Text +'=' Operator +' ' Text +'grab_and_rotate' Name +'(' Punctuation +'processes' Name +')' Punctuation +'\n ' Text +'puts' Name.Builtin +' ' Text +'"' Literal.String.Double +'Handling process ' Literal.String.Double +'#{' Literal.String.Interpol +'process' Name +'}' Literal.String.Interpol +'"' Literal.String.Double +'\n ' Text +'sleep' Name.Builtin +' ' Text +'1' Literal.Number.Integer +'\n' Text + +'end' Keyword +'\n\n\n' Text + +'# @@PLEAC@@_4.17' Comment.Single +'\n' Text + +'def' Keyword +' ' Text +'fisher_yates_shuffle' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'(' Punctuation +'a' Name +'.' Operator +'size' Name +'-' Operator +'1' Literal.Number.Integer +')' Punctuation +'.' Operator +'downto' Name +'(' Punctuation +'1' Literal.Number.Integer +')' Punctuation +' ' Text +'{' Punctuation +' ' Text +'|' Operator +'i' Name +'|' Operator +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'i' Name +'+' Operator +'1' Literal.Number.Integer +')' Punctuation +'\n ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +' ' Text +'if' Keyword +' ' Text +'i' Name +' ' Text +'!=' Operator +' ' Text +'j' Name +'\n ' Text +'}' Punctuation +'\n' Text + +'end' Keyword +'\n\n' Text + +'def' Keyword +' ' Text +'naive_shuffle' Name.Function +'(' Punctuation +'a' Name +')' Punctuation +'\n ' Text +'for' Keyword +' ' Text +'i' Name +' ' Text +'in' Keyword +' ' Text +'0' Literal.Number.Integer +'...' Operator +'a' Name +'.' Operator +'size' Name +'\n ' Text +'j' Name +' ' Text +'=' Operator +' ' Text +'rand' Name.Builtin +'(' Punctuation +'a' Name +'.' Operator +'size' Name +')' Punctuation +'\n ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +' ' Text +'=' Operator +' ' Text +'a' Name +'[' Operator +'j' Name +']' Operator +',' Punctuation +' ' Text +'a' Name +'[' Operator +'i' Name +']' Operator +'\n ' Text +'end' Keyword +'\n' Text + +'end' Keyword +'\n' Text |
