fork(10) download
  1. regex = /s$/ # test: anything ending with "s"
  2.  
  3. singular = [ "car",
  4. "boat",
  5. "man",
  6. "woman",
  7. "omen",
  8. "bus",
  9. "cactus",
  10. "spy",
  11. "pie",
  12. "louse",
  13. "mouse",
  14. "amice",
  15. "goose",
  16. "creese",
  17. "person",
  18. "child",
  19. "siren",
  20. "ox",
  21. "foot",
  22. "tooth",
  23. "formula",
  24. "minx",
  25. "sphinx",
  26. "wife",
  27. "knife",
  28. "ion",
  29. "criterion",
  30. "jinni",
  31. "zero",
  32. "hero" ]
  33.  
  34. plural = [ "cars",
  35. "boats",
  36. "men",
  37. "women",
  38. "omens",
  39. "buses",
  40. "cacti",
  41. "spies",
  42. "pies",
  43. "lice",
  44. "mice",
  45. "amices",
  46. "geese",
  47. "creeses",
  48. "people",
  49. "children",
  50. "sirens",
  51. "oxen",
  52. "feet",
  53. "teeth",
  54. "formulae",
  55. "minxes",
  56. "sphinges",
  57. "wives",
  58. "knives",
  59. "ions",
  60. "criteria",
  61. "jinn",
  62. "zeros",
  63. "heroes" ]
  64.  
  65. singular.zip(plural) { |s,p|
  66. puts " #{s=~regex ? "X" : " "} #{s.ljust(9)} #{p=~regex ? "X" : " "} "+p
  67. }
  68.  
  69.  
  70. # match_singular = singular.select { |word| word =~ regex }
  71. # puts "MATCHED #{match_singular.size}/#{singular.size} singular nouns:"
  72. # puts match_singular
  73. # puts
  74. # match_plural = plural.select { |word| word =~ regex }
  75. # puts "MATCHED #{match_plural.size}/#{plural.size} plural nouns:"
  76. # puts match_plural
  77.  
Success #stdin #stdout 0.01s 7460KB
stdin
Standard input is empty
stdout
   car         X cars
   boat        X boats
   man           men
   woman         women
   omen        X omens
 X bus         X buses
 X cactus        cacti
   spy         X spies
   pie         X pies
   louse         lice
   mouse         mice
   amice       X amices
   goose         geese
   creese      X creeses
   person        people
   child         children
   siren       X sirens
   ox            oxen
   foot          feet
   tooth         teeth
   formula       formulae
   minx        X minxes
   sphinx      X sphinges
   wife        X wives
   knife       X knives
   ion         X ions
   criterion     criteria
   jinni         jinn
   zero        X zeros
   hero        X heroes