Permalink
Browse files

Merge branch 'master' of github.com:rwldrn/subjectisdead

* 'master' of github.com:rwldrn/subjectisdead:
  Adding PHP.
  Add Clojure version.
  Add C++ version.
  Make Python version crashier.
  Add Perl version.
  Fix filenames.
  Do actual replacement rather than concatenation.
  Add Python version.
  Add Ruby version.
  really removes js/readme.md
  Renames js/subject-is-dead.js
  Add Haskell version.
  Add original tweets.
  • Loading branch information...
2 parents 154d973 + 84bb998 commit 89d78f6d90291f61f69d752cc104e88dbd586bf1 @rwaldron rwaldron committed Nov 23, 2011
View
@@ -0,0 +1,2 @@
+Run using `clj subject-is-dead.clj`.
+Make sure clojure-contrib is installed an in your `$CLASSPATH`.
@@ -0,0 +1,9 @@
+(ns subject-is-dead
+ (:require [clojure.contrib.string :as str]))
+
+(def subject "[Subject] is dead, long live [Subject]")
+(def regex #"\[Subject\]")
+
+(while (re-find regex subject)
+ (def subject (str/replace-re regex subject subject))
+ (print subject))
View
@@ -0,0 +1,2 @@
+Compile using `clang++ -std=c++0x -stdlib=libc++ subject-is-dead.cpp -o subject-is-dead`.
+Then run using `./subject-is-dead`.
View
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <regex>
+#include <string>
+
+using namespace std;
+
+int main() {
+ string subject = "[Subject] is dead, long live [Subject]";
+ regex regex("\\[Subject\\]");
+
+ while (regex_search(subject.begin(), subject.end(), regex)) {
+ subject = regex_replace(subject, regex, subject);
+ cout << subject;
+ }
+ return 0;
+}
View
@@ -0,0 +1,31 @@
+import Data.Function
+import Data.List
+
+spanList _ [] = ([],[])
+spanList func list@(x:xs) =
+ if func list
+ then (x:ys,zs)
+ else ([],list)
+ where (ys,zs) = spanList func xs
+
+breakList func = spanList (not . func)
+
+join delim l = concat (intersperse delim l)
+
+replace old new l = join new . split old $ l
+
+split _ [] = []
+split delim str =
+ let (firstline, remainder) = breakList (isPrefixOf delim) str
+ in
+ firstline : case remainder of
+ [] -> []
+ x -> if x == delim
+ then [] : []
+ else split delim
+ (drop (length delim) x)
+
+
+subject s = replace "[Subject]" s s
+
+main = print . intercalate " " $ iterate subject "[Subject] is dead, long live [Subject]"
View
@@ -0,0 +1,6 @@
+Usage:
+
+```bash
+perl subject-is-dead.pl
+./subject-is-dead.pl
+```
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env perl
+
+$subject = "[Subject] is dead, long live [Subject]";
+
+while ($subject =~ /\[Subject\]/) {
+ $subject =~ s/\[Subject\]/$subject/ge;
+ print $subject . "\n";
+}
View
@@ -0,0 +1,7 @@
+Usage:
+
+```bash
+php subject-is-dead.php
+./subject-is-dead.php
+```
+![Subject is dead, long live Subject](http://grimhappy.com/i/cff1b.png)
View
@@ -0,0 +1,8 @@
+#!/usr/bin/php
+<?php
+
+$subject = "[Subject] is dead, long live [Subject]";
+$pattern = "/\[Subject\]/";
+
+while (TRUE)
+ echo preg_replace($pattern, $subject, &$subject);
View
@@ -0,0 +1 @@
+Run using `python subject.py`.
@@ -0,0 +1,9 @@
+import re
+
+subject = "[Subject] is dead, long live [Subject]"
+regex = r"\[Subject\]";
+
+if __name__ == "__main__":
+ while re.match(regex, subject):
+ subject = re.sub(regex, subject, subject)
+ print(subject)
View
@@ -0,0 +1,6 @@
+Usage:
+
+```bash
+ruby subject-is-dead.rb
+./subject-is-dead.rb
+```
View
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+
+subject = "[Subject] is dead, long live [Subject]"
+pattern = /\[Subject\]/
+
+while pattern =~ subject
+ subject.gsub! pattern, subject
+ puts subject
+end

0 comments on commit 89d78f6

Please sign in to comment.