about summary refs log tree commit diff
path: root/lang
diff options
context:
space:
mode:
Diffstat (limited to 'lang')
-rw-r--r--lang/cpptour/README.md10
-rw-r--r--lang/cpptour/Vector-test.cc29
-rw-r--r--lang/cpptour/Vector.cc38
-rw-r--r--lang/cpptour/Vector.h12
-rw-r--r--lang/cpptour/abstract.cc19
-rw-r--r--lang/cpptour/abstract.h18
-rw-r--r--lang/cpptour/count.cc11
-rw-r--r--lang/cpptour/enumcls.cc28
-rw-r--r--lang/cpptour/helloworld.cc7
-rw-r--r--lang/cpptour/mycomplex.cc67
-rw-r--r--lang/cpptour/mycomplex.h15
-rw-r--r--lang/cpptour/myvec.cc36
-rw-r--r--lang/cpptour/square.cc21
-rw-r--r--lang/cpptour/static-ass.cc8
-rw-r--r--lang/cpptour/veccls.cc32
-rw-r--r--lang/cpptour/vecuser.cc28
-rw-r--r--lang/cpptour/weirdo.cc83
-rw-r--r--lang/mips/chapter-2/exercise-1/a.s20
-rw-r--r--lang/mips/chapter-2/exercise-1/b.s19
-rw-r--r--lang/mips/chapter-2/exercise-1/c.s15
-rw-r--r--lang/mips/chapter-2/exercise-1/d.s13
-rw-r--r--lang/mips/chapter-2/exercise-1/e.s18
-rw-r--r--lang/mips/chapter-2/exercise-1/f.s17
-rw-r--r--lang/mips/chapter-2/exercise-1/g.s19
-rw-r--r--lang/mips/chapter-2/exercise-1/h.s20
-rw-r--r--lang/mips/chapter-2/exercise-1/i.s12
-rw-r--r--lang/mips/chapter-2/exercise-1/j.s16
-rw-r--r--lang/mips/chapter-2/exercise-1/k.s28
-rw-r--r--lang/mips/chapter-2/exercise-1/l.s22
-rw-r--r--lang/mips/chapter-2/exercise-1/m.s17
-rw-r--r--lang/mips/chapter-2/exercise-1/n.s16
-rw-r--r--lang/mips/chapter-2/exercise-1/o.s17
-rw-r--r--lang/mips/chapter-2/exercise-1/p.s21
-rw-r--r--lang/mips/chapter-2/exercise-1/q.s20
-rw-r--r--lang/mips/chapter-2/exercise-1/r.s16
-rw-r--r--lang/mips/chapter-2/exercise-1/s.s16
-rw-r--r--lang/mips/chapter-2/exercise-3.s22
-rw-r--r--lang/mips/chapter-2/exercise-5.s22
-rw-r--r--lang/mips/chapter-3/exercise-10.s41
-rw-r--r--lang/mips/chapter-3/exercise-11.s41
-rw-r--r--lang/mips/chapter-3/exercise-13.s18
-rw-r--r--lang/mips/chapter-3/exercise-14.s19
-rw-r--r--lang/mips/chapter-3/exercise-15.s19
-rw-r--r--lang/mips/chapter-3/exercise-16.s19
-rw-r--r--lang/mips/chapter-3/exercise-3.s20
-rw-r--r--lang/mips/chapter-3/exercise-4.s20
-rw-r--r--lang/mips/chapter-3/exercise-6.s47
-rw-r--r--lang/mips/chapter-3/exercise-7.s47
-rw-r--r--lang/mips/mips.pdfbin0 -> 643292 bytes
-rwxr-xr-xlang/thinkraku/draft.raku298
-rwxr-xr-xlang/thinkraku/human-seconds.raku8
-rwxr-xr-xlang/thinkraku/merry-christmas.raku2
52 files changed, 1447 insertions, 0 deletions
diff --git a/lang/cpptour/README.md b/lang/cpptour/README.md
new file mode 100644
index 0000000..b60cb65
--- /dev/null
+++ b/lang/cpptour/README.md
@@ -0,0 +1,10 @@
+A Tour of C++
+-------------
+
+These are my draft while following Bjarne Stroustrup tour to learn some C++11.
+Not that I eventually fell for the language, but I did realize that I simply
+cannot evite it forever. In fact, this is the preparation for a Python
+extension.
+
+Since the book is non-free (in either sense), I may not upload it. However,
+one could try to look for it in a *lib*rary. *Gen*erally it's available.
diff --git a/lang/cpptour/Vector-test.cc b/lang/cpptour/Vector-test.cc
new file mode 100644
index 0000000..fbdf129
--- /dev/null
+++ b/lang/cpptour/Vector-test.cc
@@ -0,0 +1,29 @@
+#include <cassert>
+#include <iostream>
+#include <stdexcept>
+
+#include "Vector.h"
+
+using namespace std;
+
+void
+neg_length ()
+{
+  try { Vector v (-27); }
+  catch (length_error) { cout << "it's alright" << endl; }
+  catch (bad_alloc) { cout << "BIG OOF!" << endl; }
+}
+
+void
+init ()
+{
+  Vector v {7.4, 3.2, 5.2, 6.9, 9.5, 4.2, 21.7};
+  assert(v[5] == 4.2);
+}
+
+int
+main ()
+{
+  neg_length ();
+  init ();
+}
diff --git a/lang/cpptour/Vector.cc b/lang/cpptour/Vector.cc
new file mode 100644
index 0000000..8f94345
--- /dev/null
+++ b/lang/cpptour/Vector.cc
@@ -0,0 +1,38 @@
+#include <stdexcept>
+
+#include "Vector.h"
+
+using namespace std;
+
+Vector::Vector (int s)
+{
+  if (s < 0)
+    throw length_error{"You're being negetive!"};
+  elem = new double[s];
+  sz = s;
+}
+
+Vector::Vector (initializer_list<double> lst)
+: elem {new double[lst.size()]}, sz {static_cast<int> (lst.size())}
+{
+  copy(lst.begin(), lst.end(), elem);
+}
+
+Vector::~Vector ()
+{
+  delete[] elem;
+}
+
+int
+Vector::size () noexcept
+{
+  return sz;
+}
+
+double&
+Vector::operator[] (int i)
+{
+  if (i < 0 || size() <= i)
+    throw out_of_range{"Vector::operator[]"};
+  return elem[i];
+}
diff --git a/lang/cpptour/Vector.h b/lang/cpptour/Vector.h
new file mode 100644
index 0000000..8508503
--- /dev/null
+++ b/lang/cpptour/Vector.h
@@ -0,0 +1,12 @@
+class Vector {
+public:
+  Vector (int s);
+  Vector (std::initializer_list<double>);
+  ~Vector ();
+  double& operator[] (int i);
+  int size () noexcept;
+  void push_back (double);
+private:
+  double* elem;
+  int sz;
+};
diff --git a/lang/cpptour/abstract.cc b/lang/cpptour/abstract.cc
new file mode 100644
index 0000000..f747a37
--- /dev/null
+++ b/lang/cpptour/abstract.cc
@@ -0,0 +1,19 @@
+Vector_container:Vector_container (int s) : v (s)
+{
+}
+
+Vector_container:~Vector_container ()
+{
+}
+
+double&
+Vector_container:operator[] (int i)
+{
+  return v[i];
+}
+
+int
+size () const
+{
+  return v.size ();
+}
diff --git a/lang/cpptour/abstract.h b/lang/cpptour/abstract.h
new file mode 100644
index 0000000..71191d9
--- /dev/null
+++ b/lang/cpptour/abstract.h
@@ -0,0 +1,18 @@
+#include "Vector.h"
+
+class Container {
+public:
+  virtual double& operator[] (int) = 0;
+  virtual int size () const = 0;
+  virtual ~Container () {}
+};
+
+class Vector_container : public Container {
+  Vector v;
+public:
+  Vector_container (int);
+  ~Vector_container ();
+
+  double& operator[] (int);
+  int size () const;
+};
diff --git a/lang/cpptour/count.cc b/lang/cpptour/count.cc
new file mode 100644
index 0000000..a047f04
--- /dev/null
+++ b/lang/cpptour/count.cc
@@ -0,0 +1,11 @@
+#include <iostream>
+
+using namespace std;
+
+int
+main ()
+{
+  int v[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+  for (auto& x : v)
+    cout << x << endl;
+}
diff --git a/lang/cpptour/enumcls.cc b/lang/cpptour/enumcls.cc
new file mode 100644
index 0000000..2340f65
--- /dev/null
+++ b/lang/cpptour/enumcls.cc
@@ -0,0 +1,28 @@
+#include <iostream>
+
+using namespace std;
+
+enum class Color { red, blue, green };
+enum class TraficLight { green, yellow, red };
+
+TraficLight& operator++ (TraficLight& t)
+{
+  switch (t)
+    {
+    case TraficLight::green:
+      return t = TraficLight::yellow;
+    case TraficLight::yellow:
+      return t = TraficLight::red;
+    case TraficLight::red:
+      return t = TraficLight::green;
+    }
+}
+
+int
+main ()
+{
+  Color col = Color::red;
+  TraficLight light = TraficLight::red;
+  TraficLight nxt = ++light;
+  // ugh now we test if it compiles? just wanna build some muscle memory
+}
diff --git a/lang/cpptour/helloworld.cc b/lang/cpptour/helloworld.cc
new file mode 100644
index 0000000..89a7f8a
--- /dev/null
+++ b/lang/cpptour/helloworld.cc
@@ -0,0 +1,7 @@
+#include <iostream>
+
+int
+main ()
+{
+  std::cout << "Hello, World!" << std::endl;
+}
diff --git a/lang/cpptour/mycomplex.cc b/lang/cpptour/mycomplex.cc
new file mode 100644
index 0000000..fade98f
--- /dev/null
+++ b/lang/cpptour/mycomplex.cc
@@ -0,0 +1,67 @@
+#include "mycomplex.h"
+
+constexpr double
+square (double x)
+{
+  return x * x;
+}
+
+complex&
+operator*= (complex& a, complex b)
+{
+  double r = a.real() * b.real() - a.imag() * b.imag();
+  double i = a.real() * b.imag() + a.imag() * b.real();
+  a.real(r);
+  a.imag(i);
+  return a;
+}
+
+complex&
+operator/= (complex& a, complex b)
+{
+  double d = square(b.real()) + square(b.imag());
+  complex c {b.real() / d, -b.imag() / d};
+  return a *= c;
+}
+
+complex
+operator+ (complex a, complex b)
+{
+  return a += b;
+}
+
+complex
+operator- (complex a, complex b)
+{
+  return a -= b;
+}
+
+complex
+operator- (complex a)
+{
+  return {-a.real(), -a.imag()};
+}
+
+complex
+operator* (complex a, complex b)
+{
+  return a *= b;
+}
+
+complex
+operator/ (complex a, complex b)
+{
+  return a /= b;
+}
+
+bool
+operator== (complex a, complex b)
+{
+  return a.real() == b.real() && a.imag() == b.imag();
+}
+
+bool
+operator!= (complex a, complex b)
+{
+  return !(a == b);
+}
diff --git a/lang/cpptour/mycomplex.h b/lang/cpptour/mycomplex.h
new file mode 100644
index 0000000..b7440ee
--- /dev/null
+++ b/lang/cpptour/mycomplex.h
@@ -0,0 +1,15 @@
+class complex {
+  double re, im;
+public:
+  complex (double r, double i) : re {r}, im {i} {}
+  complex (double r) : re {r}, im {0.0} {}
+  complex () : re {0.0}, im {0.0} {}
+
+  double real () const { return re; }
+  void real (double r) { re = r; }
+  double imag () const { return im; }
+  void imag (double i) { im = i; }
+
+  complex& operator+= (complex z) { re += z.re, im += z.im; return *this; }
+  complex& operator-= (complex z) { re -= z.re, im -= z.im; return *this; }
+};
diff --git a/lang/cpptour/myvec.cc b/lang/cpptour/myvec.cc
new file mode 100644
index 0000000..1314730
--- /dev/null
+++ b/lang/cpptour/myvec.cc
@@ -0,0 +1,36 @@
+#include <iostream>
+
+using namespace std;
+
+struct Vector
+{
+  int sz;       // number of elements
+  double* elem; // pointer to elements
+};
+
+void
+vector_init (Vector& v, int s)
+{
+  v.elem = new double[s];
+  v.sz = s;
+}
+
+double
+read_and_sum (int s)
+{
+  Vector v;
+  vector_init (v, s);
+  for (int i = 0; i != s; ++i)
+    cin >> v.elem[i];
+
+  double sum = 0;
+  for (int i = 0; i != s; ++i)
+    sum += v.elem[i];
+  return sum;
+}
+
+int
+main ()
+{
+  cout << read_and_sum (5) << endl;
+}
diff --git a/lang/cpptour/square.cc b/lang/cpptour/square.cc
new file mode 100644
index 0000000..fb14456
--- /dev/null
+++ b/lang/cpptour/square.cc
@@ -0,0 +1,21 @@
+#include <iostream>
+
+using namespace std;
+
+double
+square (double x)
+{
+  return x * x;
+}
+
+void
+print_square (double x)
+{
+  cout << "the quare of " << x << " is " << square (x) << endl;
+}
+
+int
+main ()
+{
+  print_square (1.234);
+}
diff --git a/lang/cpptour/static-ass.cc b/lang/cpptour/static-ass.cc
new file mode 100644
index 0000000..837a965
--- /dev/null
+++ b/lang/cpptour/static-ass.cc
@@ -0,0 +1,8 @@
+constexpr double C = 2999792.458;   // km/s
+
+int
+main ()
+{
+  constexpr double local_max = 160.0 / (60 * 60);
+  static_assert (local_max < C, "can't go that fast");
+}
diff --git a/lang/cpptour/veccls.cc b/lang/cpptour/veccls.cc
new file mode 100644
index 0000000..0162d23
--- /dev/null
+++ b/lang/cpptour/veccls.cc
@@ -0,0 +1,32 @@
+#include <iostream>
+
+using namespace std;
+
+class Vector {
+public:
+  Vector (int s) : elem {new double[s]}, sz {s} {}  // construct a Vector
+  double& operator[] (int i) { return elem[i]; }    // random access
+  int size () { return sz; }
+private:
+  double* elem; // pointer to the elements
+  int sz;       // the number of elements
+};
+
+double
+read_and_sum (int s)
+{
+  Vector v (s);
+  for (int i = 0; i != v.size (); ++i)
+    cin >> v[i];
+
+  double sum = 0;
+  for (int i = 0; i != v.size (); ++i)
+    sum += v[i];
+  return sum;
+}
+
+int
+main ()
+{
+  cout << read_and_sum (5) << endl;
+}
diff --git a/lang/cpptour/vecuser.cc b/lang/cpptour/vecuser.cc
new file mode 100644
index 0000000..0eefb0e
--- /dev/null
+++ b/lang/cpptour/vecuser.cc
@@ -0,0 +1,28 @@
+#include <cmath>
+#include <iostream>
+#include <stdexcept>
+
+#include "Vector.h"
+
+using namespace std;
+
+double
+sqrt_sum (Vector& v)
+{
+  double sum = 0;
+  for (int i = 0; i <= v.size(); ++i)
+    try { sum += sqrt(v[i]); }
+    catch (out_of_range) { cout << "Yeet!" << endl; }
+  return sum;
+}
+
+int
+main ()
+{
+  int n;
+  cin >> n;
+  Vector v (n);
+  while (n--)
+    cin >> v[n];
+  cout << sqrt_sum (v) << endl;
+}
diff --git a/lang/cpptour/weirdo.cc b/lang/cpptour/weirdo.cc
new file mode 100644
index 0000000..f79336c
--- /dev/null
+++ b/lang/cpptour/weirdo.cc
@@ -0,0 +1,83 @@
+#include <iostream>
+#include <set>
+#include <stdexcept>
+#include <string>
+#include <unordered_map>
+
+using namespace std;
+
+typedef unordered_map<char, size_t> charmap;
+typedef set<char> charset;
+
+constexpr double INF = 1e7;
+const charset VOWELS {'a', 'e', 'i', 'o', 'u'};
+
+inline size_t
+sqr (size_t i)
+{
+  return i * i;
+}
+
+bool
+isvowel (const string& s, size_t i)
+{
+  try { return VOWELS.count (s.at (i)); }
+  catch (out_of_range const& e) { return true; }
+}
+
+void
+update (const string& s, charmap& x, charmap& f)
+{
+  charset b;
+  for (const auto& c : s)
+    {
+      f[c]++;
+      b.insert (c);
+    }
+  for (const auto& c : b)
+    x[c]++;
+}
+
+int
+main ()
+{
+  size_t t, l;
+  string s;
+
+  cin >> t;
+  while (t--)
+    {
+      charmap xa, fa, xb, fb;
+      cin >> l;
+      while (l--)
+        {
+          cin >> s;
+          size_t i = s.size ();
+          bool a = true;
+
+          while (i--)
+            if (isvowel (s, i - 1) + isvowel (s, i) + isvowel (s, i + 1) < 2)
+              {
+                update (s, xb, fb);
+                a = false;
+                break;
+              }
+          if (a)
+            update (s, xa, fa);
+        }
+
+      double sc = 1.0;
+      for (const auto& p : xa)
+        sc *= p.second;
+      for (const auto& p : fa)
+        sc /= sqr (p.second);
+      for (const auto& p : xb)
+        sc /= p.second;
+      for (const auto& p : fb)
+        sc *= sqr (p.second);
+      if (sc > INF)
+        cout << "Infinity" << endl;
+      else
+        cout << sc << endl;
+    }
+}
diff --git a/lang/mips/chapter-2/exercise-1/a.s b/lang/mips/chapter-2/exercise-1/a.s
new file mode 100644
index 0000000..4da4645
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/a.s
@@ -0,0 +1,20 @@
+# t3 = t4 + t5 - t6
+	.text
+main:
+	li	$t4,	4		# t4 = 4
+	li	$t5,	5		# t5 = 5
+	li	$t6,	6		# t6 = 6
+
+	add	$t3,	$t4,	$t5	# t3 = t4 + t5
+	sub	$t3,	$t3,	$t6	# t3 -= t6
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t3		# at t3
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/b.s b/lang/mips/chapter-2/exercise-1/b.s
new file mode 100644
index 0000000..fa590b5
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/b.s
@@ -0,0 +1,19 @@
+# s3 = t2 / (s1 - 54321)
+	.text
+main:
+	li	$t2,	69		# t2 = 69
+	li	$s1,	54324		# s1 = 54324
+
+	sub	$s1,	$s1,	54321	# s1 -= 54321
+	div	$t3,	$t2,	$s1	# t3 = t2 / s1
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t3		# at a0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/c.s b/lang/mips/chapter-2/exercise-1/c.s
new file mode 100644
index 0000000..370af96
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/c.s
@@ -0,0 +1,15 @@
+# sp -= 16
+	.text
+main:
+	addi	$sp,	$sp,	-16	# sp -= 16, may underflow
+
+	li	$v0,	1		# print integer
+	move	$a0,	$sp		# at sp
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/d.s b/lang/mips/chapter-2/exercise-1/d.s
new file mode 100644
index 0000000..e20cd4c
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/d.s
@@ -0,0 +1,13 @@
+# print t3
+	.text
+main:
+	li	$v0,	1		# print integer
+	move	$a0,	$t3		# at t3
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/e.s b/lang/mips/chapter-2/exercise-1/e.s
new file mode 100644
index 0000000..d35702d
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/e.s
@@ -0,0 +1,18 @@
+# read to and echo t0
+	.text
+main:
+	li	$v0,	5		# read integer to v0
+	syscall
+
+	move	$t0,	$v0		# t0 = v0
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/f.s b/lang/mips/chapter-2/exercise-1/f.s
new file mode 100644
index 0000000..2ec14ef
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/f.s
@@ -0,0 +1,17 @@
+# a0 = array
+	.data
+array:	.word	4, 20, 6, 9
+
+	.text
+main:
+
+	li	$v0,	1		# print integer
+	la	$a0,	array		# address of array
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/g.s b/lang/mips/chapter-2/exercise-1/g.s
new file mode 100644
index 0000000..e9d8f8f
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/g.s
@@ -0,0 +1,19 @@
+# t8 = *a0
+	.data
+array:	.word	4, 20, 6, 9
+
+	.text
+main:
+	la	$a0,	array		# a0 = array
+	lw	$t8,	($a0)		# t8 = *a0
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t8		# at t8
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/h.s b/lang/mips/chapter-2/exercise-1/h.s
new file mode 100644
index 0000000..eaf63bd
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/h.s
@@ -0,0 +1,20 @@
+# a0[4] = 32768
+	.data
+array:	.word	4, 2, 0, 6, 9
+
+	.text
+main:
+	la	$a0,	array		# t0 = array
+	li	$t1,	32768		# t1 = 32768
+	sw	$t1,	16($a0)		# t0[4] = t1
+
+	li	$v0,	1		# print integer
+	lw	$a0,	16($a0)		# at t0[4]
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/i.s b/lang/mips/chapter-2/exercise-1/i.s
new file mode 100644
index 0000000..8754525
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/i.s
@@ -0,0 +1,12 @@
+# print Hello, World!
+	.data
+hello:	.asciiz "Hello, World!\n"
+
+	.text
+main:
+	li	$v0,	4		# print string
+	la	$a0,	hello		# hello
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/j.s b/lang/mips/chapter-2/exercise-1/j.s
new file mode 100644
index 0000000..95eccc7
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/j.s
@@ -0,0 +1,16 @@
+# t7 = abs(t0)
+	.text
+main:
+	li	$t0,	-420		# t0 = -420
+	abs	$t7,	$t0		# t7 = abs(t0)
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t7		# at t7
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/k.s b/lang/mips/chapter-2/exercise-1/k.s
new file mode 100644
index 0000000..60c0038
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/k.s
@@ -0,0 +1,28 @@
+# while (t0) { s1 += t0; t0 = *++t2; }
+	.data
+array:	.word	4, 2, 0, 6, 9
+
+	.text
+main:
+	la	$t2,	array		# t2 = array
+	lw	$t0,	($t2)		# t0 = *t2
+	li	$s1,	0		# s1 = 0
+
+while:
+	beqz	$t0,	end		# if (!t0) goto end
+	add	$s1,	$s1,	$t0	# s1 += t0
+	addi	$t2,	$t2,	4	# t2++
+	lw	$t0,	($t2)		# t0 = *t2
+	j	while			# goto while
+end:
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s1		# at s1
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/l.s b/lang/mips/chapter-2/exercise-1/l.s
new file mode 100644
index 0000000..73b999d
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/l.s
@@ -0,0 +1,22 @@
+# for (t1 = 99; t1 > 0; v0 += t1--)
+	.text
+main:
+	li	$v0,	0		# v0 = 0
+	li	$t1,	99		# t1 = 99
+for:
+	blez	$t1,	end		# if (t1 <= 0) goto end
+	add	$v0,	$v0,	$t1	# v0 += t1
+	addi	$t1,	$t1,	-1	# t1--
+	j	for			# goto for
+end:
+
+	move	$a0,	$v0		# a0 = v0
+	li	$v0,	1		# print integer at a0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/m.s b/lang/mips/chapter-2/exercise-1/m.s
new file mode 100644
index 0000000..e02f924
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/m.s
@@ -0,0 +1,17 @@
+# t0 = 0x7fffffff - 0x80000000
+	.text
+main:
+	li	$t2,	-0x80000000	# t2 = 0x80000000
+	li	$t1,	0x7fffffff	# t1 = 0x7fffffff
+	add	$t0,	$t1,	$t2	# t0 = t1 - t2
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/n.s b/lang/mips/chapter-2/exercise-1/n.s
new file mode 100644
index 0000000..4394ebf
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/n.s
@@ -0,0 +1,16 @@
+# s0 *= -1
+	.text
+main:
+	li	$s0,	420		# s0 = 420
+	neg	$s0,	$s0		# s0 = -s0
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s0		# at s0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/o.s b/lang/mips/chapter-2/exercise-1/o.s
new file mode 100644
index 0000000..06dfc5c
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/o.s
@@ -0,0 +1,17 @@
+# s1 *= a0
+	.text
+main:
+	li	$s1,	420		# s1 = 420
+	li	$a0,	69		# a0 = 69
+	mul	$s1,	$s1,	$a0	# s1 *= a0
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s1		# at s1
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/p.s b/lang/mips/chapter-2/exercise-1/p.s
new file mode 100644
index 0000000..a15958f
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/p.s
@@ -0,0 +1,21 @@
+# s2 = srt(s0**2 + 56) / a3
+	.text
+main:
+	li	$s0,	420		# s0 = 420
+	li	$a3,	69		# a3 = 69
+
+	mul	$t0,	$s0,	$s0	# t0 = s0 ** 2
+	addi	$a0,	$t0,	56	# a0 = t0 + 56
+	jal	srt			# v0 = srt(a0)	# srt is undefined
+	div	$s2,	$v0,	$a3	# s2 = v0 / a3
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s0		# at s2
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/q.s b/lang/mips/chapter-2/exercise-1/q.s
new file mode 100644
index 0000000..47069cd
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/q.s
@@ -0,0 +1,20 @@
+# s3 = s1 - s2 / s3
+	.text
+main:
+	li	$s1,	69		# s1 = 69
+	li	$s2,	20		# s2 = 20
+	li	$s3,	4		# s3 = 4
+
+	div	$s3,	$s2,	$s3	# s3 = s2 / s3
+	sub	$s3,	$s1,	$s3	# s3 = s1 - s3
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s3		# at s3
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/r.s b/lang/mips/chapter-2/exercise-1/r.s
new file mode 100644
index 0000000..c362e64
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/r.s
@@ -0,0 +1,16 @@
+# s4 <<= 3
+	.text
+main:
+	li	$s4,	420		# s4 = 420
+	sll	$s4,	$s4,	3	# s4 <<= 3
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s4		# at s4
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-1/s.s b/lang/mips/chapter-2/exercise-1/s.s
new file mode 100644
index 0000000..07c8a12
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-1/s.s
@@ -0,0 +1,16 @@
+# s5 *= pi
+	.text
+main:
+	li	$s5,	420		# s5 = 420
+	mul	$s5,	$s5,	3	# s5 *= 3
+
+	li	$v0,	1		# print integer
+	move	$a0,	$s5		# at s5
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate program run
+	syscall
diff --git a/lang/mips/chapter-2/exercise-3.s b/lang/mips/chapter-2/exercise-3.s
new file mode 100644
index 0000000..d82da72
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-3.s
@@ -0,0 +1,22 @@
+# t0 = (s1 - s0 / s2) * s4
+	.text
+main:
+	li	$s1,	4		# s1 = 4
+	li	$s0,	20		# s0 = 20
+	li	$s2,	6		# s2 = 6
+	li	$s4,	9		# s4 = 9
+
+	div	$t0,	$s0,	$s2	# t0 = s0 / s2
+	sub	$t0,	$s1,	$t0	# t0 = s1 - t0
+	mul	$t0,	$t0,	$s4	# t0 *= s4
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-2/exercise-5.s b/lang/mips/chapter-2/exercise-5.s
new file mode 100644
index 0000000..ffb4058
--- /dev/null
+++ b/lang/mips/chapter-2/exercise-5.s
@@ -0,0 +1,22 @@
+# t0 = s0/8 - s1*2 + s2
+	.text
+main:
+	li	$s0,	69		# s0 = 20
+	li	$s1,	4		# s1 = 4
+	li	$s2,	20		# s2 = 20
+
+	sra	$t0,	$s0,	3	# t0 = s0 >> 3
+	sll	$t1,	$s1,	1	# t1 = s1 << 1
+	sub	$t0,	$t0,	$t1	# t0 -= t1
+	add	$t0,	$t0,	$s2	# t0 += s2
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-10.s b/lang/mips/chapter-3/exercise-10.s
new file mode 100644
index 0000000..f3ddeef
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-10.s
@@ -0,0 +1,41 @@
+# print -35 in 8-bit two-complement binary
+	.text
+main:
+	li	$t0,	-35		# t0 = -35
+	li	$t1,	0		# t1 = 0
+	li	$t8,	8		# t8 = 8
+
+reverse:
+	beqz	$t8,	prefix		# if (!t8) goto prefix
+	andi	$t2,	$t0,	1	# t2 = t0 & 1
+	sra	$t0,	$t0,	1	# t0 >>= 1
+	sll	$t1,	$t1,	1	# t1 <<= 1
+	add	$t1,	$t1,	$t2	# t1 += t2
+	addi	$t8,	$t8,	-1	# t8--
+	j	reverse			# goto reverse
+
+prefix:
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	li	$v0,	11		# print character
+	li	$a0,	98		# b
+	syscall
+	li	$t8,	8		# t8 = 8
+
+print:
+	beqz	$t8,	end		# if (!t8) goto end
+	li	$v0,	1		# print integre
+	andi	$a0,	$t1,	1	# a0 = t1 & 1
+	syscall
+	sra	$t1,	$t1,	1	# t1 >>= 1
+	addi	$t8,	$t8,	-1	# t8--
+	j	print			# goto print
+
+end:
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-11.s b/lang/mips/chapter-3/exercise-11.s
new file mode 100644
index 0000000..f47f29f
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-11.s
@@ -0,0 +1,41 @@
+# print -32 in 8-bit two-complement binary
+	.text
+main:
+	li	$t0,	-32		# t0 = -32
+	li	$t1,	0		# t1 = 0
+	li	$t8,	8		# t8 = 8
+
+reverse:
+	beqz	$t8,	prefix		# if (!t8) goto prefix
+	andi	$t2,	$t0,	1	# t2 = t0 & 1
+	sra	$t0,	$t0,	1	# t0 >>= 1
+	sll	$t1,	$t1,	1	# t1 <<= 1
+	add	$t1,	$t1,	$t2	# t1 += t2
+	addi	$t8,	$t8,	-1	# t8--
+	j	reverse			# goto reverse
+
+prefix:
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	li	$v0,	11		# print character
+	li	$a0,	98		# b
+	syscall
+	li	$t8,	8		# t8 = 8
+
+print:
+	beqz	$t8,	end		# if (!t8) goto end
+	li	$v0,	1		# print integre
+	andi	$a0,	$t1,	1	# a0 = t1 & 1
+	syscall
+	sra	$t1,	$t1,	1	# t1 >>= 1
+	addi	$t8,	$t8,	-1	# t8--
+	j	print			# goto print
+
+end:
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-13.s b/lang/mips/chapter-3/exercise-13.s
new file mode 100644
index 0000000..6779d11
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-13.s
@@ -0,0 +1,18 @@
+# print(int('204', 8))
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	2	# t0 += 2
+	sll	$t0,	$t0,	6	# t0 *= 8 * 8
+	addi	$t0,	$t0,	4	# t0 += 4
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-14.s b/lang/mips/chapter-3/exercise-14.s
new file mode 100644
index 0000000..b01b76b
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-14.s
@@ -0,0 +1,19 @@
+# print(int('204', 7))
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	2	# t0 += 2
+	li	$t1,	49		# t1 = 7 * 7
+	mul	$t0,	$t0,	$t1	# t0 *= t1
+	addi	$t0,	$t0,	4	# t0 += 4
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-15.s b/lang/mips/chapter-3/exercise-15.s
new file mode 100644
index 0000000..3a16b14
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-15.s
@@ -0,0 +1,19 @@
+# print(int('204', 6))
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	2	# t0 += 2
+	li	$t1,	36		# t1 = 6 * 6
+	mul	$t0,	$t0,	$t1	# t0 *= t1
+	addi	$t0,	$t0,	4	# t0 += 4
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-16.s b/lang/mips/chapter-3/exercise-16.s
new file mode 100644
index 0000000..1aa9dec
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-16.s
@@ -0,0 +1,19 @@
+# print(int('204', 5))
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	2	# t0 += 2
+	li	$t1,	25		# t1 = 5 * 5
+	mul	$t0,	$t0,	$t1	# t0 *= t1
+	addi	$t0,	$t0,	4	# t0 += 4
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-3.s b/lang/mips/chapter-3/exercise-3.s
new file mode 100644
index 0000000..cb2475c
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-3.s
@@ -0,0 +1,20 @@
+# t0 = 0b10101, using only bit shift and add
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	1	# t0++
+	sll	$t0,	$t0,	2	# t0 <<= 2
+	addi	$t0,	$t0,	1	# t0++
+	sll	$t0,	$t0,	2	# t0 <<= 2
+	addi	$t0,	$t0,	1	# t0++
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-4.s b/lang/mips/chapter-3/exercise-4.s
new file mode 100644
index 0000000..29888f1
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-4.s
@@ -0,0 +1,20 @@
+# t0 = 0b11001, using only bit shift and add
+	.text
+main:
+	li	$t0,	0		# t0 = 0
+	addi	$t0,	$t0,	1	# t0++
+	sll	$t0,	$t0,	1	# t0 <<= 1
+	addi	$t0,	$t0,	1	# t0++
+	sll	$t0,	$t0,	3	# t0 <<= 3
+	addi	$t0,	$t0,	1	# t0++
+
+	li	$v0,	1		# print integer
+	move	$a0,	$t0		# at t0
+	syscall
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-6.s b/lang/mips/chapter-3/exercise-6.s
new file mode 100644
index 0000000..8c1b6fd
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-6.s
@@ -0,0 +1,47 @@
+# print(hex(0b10101))
+	.text
+main:
+	li	$t0,	21		# t0 = 0b10101
+	li	$t1,	0		# t1 = 0
+	li	$t9,	9		# t9 = 9
+
+reverse:
+	beqz	$t0,	done		# if (!t0) goto done
+	andi	$t2,	$t0,	0xf	# t2 = t0 & 0xf
+	sra	$t0,	$t0,	4	# t0 >>= 4
+	sll	$t1,	$t1,	4	# t1 <<= 4
+	add	$t1,	$t1,	$t2	# t1 += t2
+	j	reverse			# goto reverse
+done:
+
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	li	$v0,	11		# print character
+	li	$a0,	120		# x
+	syscall
+	bnez	$t1,	print		# if (!t1) goto print
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	j	end			# goto end
+
+print:
+	beqz	$t1,	end		# if (!t1) goto end
+	andi	$t2,	$t1,	0xf	# t2 = t1 & 0xf
+	sra	$t1,	$t1,	4	# t1 >>= 4
+	addi	$a0,	$t2,	48	# a0 = chr(t2), sort of
+	ble	$t2,	$t9,	put	# if (t2 <= 9) goto put
+	addi	$a0,	$a0,	7	# a0 += 7
+put:
+	li	$v0,	11		# print character at a0
+	syscall
+	j	print			# goto print
+end:
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/chapter-3/exercise-7.s b/lang/mips/chapter-3/exercise-7.s
new file mode 100644
index 0000000..924765d
--- /dev/null
+++ b/lang/mips/chapter-3/exercise-7.s
@@ -0,0 +1,47 @@
+# print(hex(0b11001))
+	.text
+main:
+	li	$t0,	25		# t0 = 0b11001
+	li	$t1,	0		# t1 = 0
+	li	$t9,	9		# t9 = 9
+
+reverse:
+	beqz	$t0,	done		# if (!t0) goto done
+	andi	$t2,	$t0,	0xf	# t2 = t0 & 0xf
+	sra	$t0,	$t0,	4	# t0 >>= 4
+	sll	$t1,	$t1,	4	# t1 <<= 4
+	add	$t1,	$t1,	$t2	# t1 += t2
+	j	reverse			# goto reverse
+done:
+
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	li	$v0,	11		# print character
+	li	$a0,	120		# x
+	syscall
+	bnez	$t1,	print		# if (!t1) goto print
+	li	$v0,	11		# print character
+	li	$a0,	48		# 0
+	syscall
+	j	end			# goto end
+
+print:
+	beqz	$t1,	end		# if (!t1) goto end
+	andi	$t2,	$t1,	0xf	# t2 = t1 & 0xf
+	sra	$t1,	$t1,	4	# t1 >>= 4
+	addi	$a0,	$t2,	48	# a0 = chr(t2), sort of
+	ble	$t2,	$t9,	put	# if (t2 <= 9) goto put
+	addi	$a0,	$a0,	7	# a0 += 7
+put:
+	li	$v0,	11		# print character at a0
+	syscall
+	j	print			# goto print
+end:
+
+	li	$v0,	11		# print character
+	li	$a0,	10		# newline
+	syscall
+
+	li	$v0,	10		# terminate
+	syscall
diff --git a/lang/mips/mips.pdf b/lang/mips/mips.pdf
new file mode 100644
index 0000000..4a38047
--- /dev/null
+++ b/lang/mips/mips.pdf
Binary files differdiff --git a/lang/thinkraku/draft.raku b/lang/thinkraku/draft.raku
new file mode 100755
index 0000000..cfe762d
--- /dev/null
+++ b/lang/thinkraku/draft.raku
@@ -0,0 +1,298 @@
+#!/usr/bin/env raku
+# Exercise 2.2.1
+sub sphere-volume(Numeric(Cool) $r) { 4/3 * π * $r³ }
+#put sphere-volume('5');
+
+# Exercise 3.1
+# Notice the operator precedence
+sub rjust(Str $str, Int $width = 70) { ' ' x $width - $str.chars ~ $str }
+#put rjust("Larry Wall", 80);
+
+# Exercise 3.2
+sub print-twice($str) {
+    put $str;
+    put $str
+}
+sub do-twice(&code, $arg) {
+    code $arg;
+    code $arg
+}
+#do-twice(&print-twice, "What's up doc");
+sub do-four(&code, $arg) { do-twice { do-twice &code, $_ }, $arg }
+
+# Exercise 3.3
+sub grid(Int $rows=2, Int $cols=2, Int $side=4) {
+    (('+' for 0..$cols).join((' ' for 0..$side).join('-'))~"\n" for 0..$rows)
+    .join((('|' for 0..$cols).join(' ' x $side*2 + 1)~"\n") x $side)
+}
+#print grid(4, 4);
+
+# Exercise 4.2
+sub check-fermat(Int $a, Int $b, Int $c, Int $n) {
+    return if $n <= 2;
+    if $a**$n + $b**$n == $c**$n {
+        put "Holy smokes, Fermat was wrong!"
+    } else {
+        put "No, that doesn't work."
+    }
+}
+
+# Exercise 4.3
+sub is-triangle($a, $b, $c) { ([-] reverse sort $a, $b, $c) < 0 }
+
+# Exercise 4.4
+sub fibonacci(Int $n, Int $a = 0, Int $b = 1) {
+    return $a if $n <= 0; #put $a;
+    fibonacci $n - 1, $b, $a + $b
+}
+#put fibonacci 20;
+
+sub hypotenuse($a, $o) { sqrt $a² + $o² }
+#put hypotenuse 3, 4;
+
+# Exercise 5.2
+multi ack(0, Int $n) { $n + 1 }
+multi ack(Int $m where * > 0, 0) { ack $m - 1, 1 }
+multi ack(Int $m where * > 0, Int $n where * > 0) {
+    ack $m - 1, ack($m, $n - 1)
+}
+#put ack 3, 4;
+
+# Exercise 5.3
+sub is-palindrome(Str $str) { $str eq $str.flip }
+
+# Exercise 5.4
+sub is-power-of($a, $b) { { $_ == .Int }(log $a, $b) }
+
+# Exercise 5.5: gcd is a built-in operator
+
+# Exercise 6.1
+sub my-sqrt($a, $epsilon = 0.000_000_1, $x = $a) {
+    return $x if abs $x² - $a < $epsilon;
+    my-sqrt $a, $epsilon, ($x + $a/$x) / 2
+}
+
+# Exercise 6.2
+sub factorial(Int $n) { [*] 1..$n }
+sub estimate-pi {
+    my $factor = 2 * 2.sqrt / 9801;
+    sub Srinivasa-Ramanujan($k = 1, $current = 1103, $result = 1103) {
+        my $next = factorial($k * 4) * (1103 + $k*26390)
+                   / factorial($k)⁴ / 396**($k*4);
+        return $result + $next if $factor * $next < 10**-15;
+        Srinivasa-Ramanujan $k + 1, $next, $result + $next;
+    }
+    1 / $factor / Srinivasa-Ramanujan
+}
+#put abs estimate-pi() - pi;
+
+sub ducks { map * ~ 'ack' , flat('J'..'N', 'Ou', 'P', 'Qu') }
+#put ducks;
+
+sub count(Str $string, Str $substr, Int $index = 0, Int $result = 0) {
+    my $i = index $string, $substr, $index;
+    return $result unless defined $i;
+    count $string, $substr, $i + 1, $result + 1
+}
+#put count 'banana', 'na';
+
+sub bubble-sort(@seq is copy) {
+    my $done;
+    repeat {
+        $done = True;
+        for ^@seq.end -> $i {
+            if @seq[$i] > @seq[$i+1] {
+                @seq[$i, $i + 1] .= reverse
+                $done = False
+            }
+        }
+    } until $done;
+    @seq
+}
+#put bubble-sort <4 2 6 5 3 9 1>;
+
+sub select-sort(@seq is copy) {
+    for ^@seq.end -> $i {
+        for $i..@seq.end -> $j {
+            @seq[$i, $j] .= reverse if @seq[$i] > @seq[$j]
+        }
+    }
+    @seq
+}
+#put select-sort <4 2 6 5 3 9 1>;
+
+sub insert-sort(@seq is copy) {
+    for 1..@seq.end -> $i {
+        loop (my $j = $i; $j and @seq[$j] < @seq[$j - 1]; $j--) {
+            @seq[$j, $j - 1] .= reverse
+        }
+    }
+    @seq
+}
+#put insert-sort <4 2 6 5 3 9 1>;
+
+# Some simple regexes
+#put $/ if "π ≈ $(π)" ~~ /\d**10/;
+#put $/ if '1234567890' ~~ /^ <[0..7]>+ $/;
+#put $/ if ' Hello, World!' ~~ /\w+/;
+#put $/ if 'qaz asdf zxcv' ~~ /<< a \w*/;
+#put $/ if 'hmmm ooer' ~~ /<< <[aeiou]> \w*/;
+#put $/ if '0621323 0612345678- 0701234567' ~~ /<< 0 <[67]> \d**8 >>/;
+#put $/ if 'hMmM OoEr' ~~ /:i << <[aeiou]> \w*/;
+#put $/ if 'hmmm ooer' ~~ /(\w)$0/;
+#put $1 if 'hmmm ooer' ~~ /(\w) $0 .* ((\w) $0)/;
+
+sub YYYY-MM-DD(Str $string) {
+    "$0-$1-$2" if $string ~~ /<< (\d\d\d\d) \- (\d\d) \- (\d\d) >>
+    <?{0 < $1 < 13 && $2 && ($1 - 2 && $2 < 31 + ($1 - 1)%7%%2 ||
+                             $2 < 29 + $0%%400 + ($0%100)*($0%%4))}>/
+}
+#put YYYY-MM-DD '986-05-19-1700-02-29-1234-11-31-01-10-2000-02-29';
+
+# Exercise 7.3
+sub rotate-ascii(Str $string, Int $rotation) {
+    $string.comb.map({ m/<[A..Z]>/ && chr(65 + ($/.ord + $rotation - 65)%26) ||
+                       m/<[a..z]>/ && chr(97 + ($/.ord + $rotation - 97)%26) ||
+                       $_ }).join
+}
+#put rotate-ascii 'cheer', 7;
+#put rotate-ascii 'melon', -10;
+#put rotate-ascii 'HAL', 1;
+
+# Exercise 8.1
+#.put if .chars > 20 for '/usr/share/dict/words'.IO.lines;
+
+# Exercise 8.2
+sub words(&predicate) { '/usr/share/dict/words'.IO.lines.grep(&predicate) }
+#.put for words({ not /<[Ee]>/ });
+
+# Exercise 8.3
+multi avoids(@letters, @forbidden) { ($_ ∉ @letters for @forbidden).all }
+multi avoids(Str $word, Str $forbidden) { avoids $word.comb, $forbidden.comb }
+sub least-forbidden(Int $n) {
+    my %avoids = [$_ => {} for 'a'..'z'];
+    for '/usr/share/dict/words'.IO.lines.map(~*.lc).unique -> $word {
+        %avoids{$_}{$word} = True unless defined index $word, $_ for 'a'..'z';
+    }
+
+    # Despacito (baby take it slow so we can last long)
+    [([∩] %avoids{$_}).elems => $_ for combinations('a'..'z', $n)].max.value
+}
+# Unless run on a supercomputer, there ain't no way
+# one has the patience to wait for it to finish.
+#say least-forbidden 5;
+
+# Exercise 8.4
+#.put for words { m:i/^ <[acefhlo]>+ $/ };
+
+# Exercise 8.5
+my @uses-all = <a e i o u y>;
+#.put for words { (defined index $^word, $_ for @uses-all).all };
+
+# Exercise 8.6
+sub is-abcdedarian(Str $word) { [lt] $word.lc.comb }
+#.put for words &is-abcdedarian;
+
+# Exercise 8.7
+#.put for words { m/(.) $0 (.) $1 (.) $2/ };
+
+# Exercise 8.8
+#.put if [.substr(2), substr($_ + 1, 1), substr($_ + 2, 1, 4), ~($_ + 4)]
+#        .map(&is-palindrome).all for 100_000..999_996;
+
+# Exercise 8.9
+sub age-reversible(Int $times) {
+    for '10'..'90' -> $car {
+        my $diff = $car - $car.flip;
+        my @reversible = grep { .flip == $_ - $diff }, $car..'99';
+        return @reversible if @reversible == $times
+    }
+}
+#put age-reversible(8)[*-3].flip;
+
+# Exercise 9.1
+multi nested-sum(Numeric $number) { $number }
+multi nested-sum(@array) { @array.map(&nested-sum).sum }
+#put nested-sum [1, 2, [3, 4], [5, [6, 7]], [[8], [9, [10]]]];
+
+# Exercise 9.2
+#put [\+] 1..4;
+
+# Exercise 9.5
+#put [≤] (1, 2, 2);
+#put [≤] (1, 2, 1);
+
+# Exercise 9.6
+sub is-anagram(Str $this, Str $that) { $this.comb.sort ~~ $that.comb.sort }
+#put is-anagram 'this', 'shit';
+
+# Exercise 9.7
+sub has-duplicates(@array) { @array.unique != @array }
+#put has-duplicates <o o e r>;
+
+# Exercise 9.8
+sub birthday-paradox(Int $n, Int $T) {
+    sum(map { has-duplicates map { 365.25.rand.Int }, ^$n }, ^$T) / $T
+}
+#put birthday-paradox 23, 10000;
+
+# Exercise 9.10
+sub bisect(@a, $x, Int $low = 0, Int $high = @a.elems) {
+    return unless $low < $high;
+    my $mid = ($low + $high) div 2;
+    given @a[$mid] cmp $x {
+        when Less { bisect @a, $x, $mid + 1, $high }
+        when Same { $mid }
+        when More { bisect @a, $x, $low, $mid }
+    }
+}
+
+# Exercise 9.11
+#my @words = '/usr/share/dict/words'.IO.lines;
+#put "$_ $(.flip)" if /^(.)$0*$/ ^ defined bisect @words, .flip for @words;
+
+# Exercise 9.12
+sub interlock(Str $word, @words) {
+    my ($evens, $odds);
+    for $word.comb -> $even, $odd = '' {
+        $evens ~= $even;
+        $odds ~= $odd
+    }
+    bisect(@words, $evens).defined && bisect(@words, $odds).defined
+}
+#my @words = '/usr/share/dict/words'.IO.lines;
+#.put for @words.grep:{ interlock($_, @words) };
+
+# Exercise 10.3
+sub hash-duplicates(@array) {
+    my %hash;
+    for @array {
+        return True if %hash{$_};
+        %hash{$_} = True
+    }
+    False
+}
+#put hash-duplicates <o o e r>;
+
+# Exercise 10.4
+sub rotations {
+    my %words = '/usr/share/dict/words'.IO.lines.grep(/^ <[a..z]>+ $/).Set;
+    my @result;
+    for %words.keys -> $word {
+        next unless %words{$word};
+        (%words{$word}, $_) = False, $word;
+        my $virgin = True;
+        loop (tr/a..z/b..za/; $_ cmp $word; tr/a..z/b..za/) {
+            next unless %words{$_};
+            %words{$_} = False;
+            if $virgin {
+                $virgin = False;
+                @result.push([$word, $_])
+            } else {
+                @result[*-1].push($_)
+            }
+        }
+    }
+    @result
+}
+.put for rotations;
diff --git a/lang/thinkraku/human-seconds.raku b/lang/thinkraku/human-seconds.raku
new file mode 100755
index 0000000..610213e
--- /dev/null
+++ b/lang/thinkraku/human-seconds.raku
@@ -0,0 +1,8 @@
+#!/usr/bin/env raku
+# Exercise 4.1
+sub MAIN(Int $seconds=240_000) {
+    put 'Days: ', $seconds div 86400;
+    put 'Hours: ', $seconds div 3600 % 24;
+    put 'Minutes: ', $seconds div 60 % 60;
+    put 'Seconds: ', $seconds % 60
+}
diff --git a/lang/thinkraku/merry-christmas.raku b/lang/thinkraku/merry-christmas.raku
new file mode 100755
index 0000000..654f5af
--- /dev/null
+++ b/lang/thinkraku/merry-christmas.raku
@@ -0,0 +1,2 @@
+#!/usr/bin/env raku
+sub MAIN(Str $name) { put "Merry Christmas, $name!" }