99 Clojure Problems (5-6)

Clojure’s been strange so far. After tinkering in F# for the last couple months, it seems like functional programming should be easier by now.

Reverse and palindrome were easy enough, though.

; P05 (*) Reverse a list.
; clojure already has a (reverse l)
(defn s99_reverse [l]
  (loop [remain l
         curr '()] 
    (let [head (first remain)
         tail (rest remain)]
      (if (nil? head) curr (recur tail (cons head curr)))))

; P06 (*) Find out whether a list is a palindrome.
(defn isPalindrome [l] (= l (reverse l)))

I’m slowly getting my brain around the lisp like syntax, but it appears that some of the idioms are different. I’ll discuss this more when I get to the next set.

99 Clojure Problems (1-4)

I’ve been learning new languages lately, and I’ve been using the 99 scala problems to help me learn important features of the languages.

I’m going to blog about my experiences with clojure.

Once I got through the hoops of starting with clojure (just download the eclipse plugin and go!), it was smooth sailing for the first four problems.

(ns s99)
;; P01 (*) Find the last element of a list.
; Basically, this replicates the (last n) functionality already in clojure
(defn s99_last [input]
  (loop [i input]
    (let [a (first i)
          b (first (rest i))]
      (if (= b nil) a (recur (rest i))))))

; P02 (*) Find the last but one element of a list.
(defn penultimate [input] 
  (loop [i input]
	  (let [a (first i) 
	        b (first (rest i))
	        c (first (rest (rest i)))] 
	    (if (nil? c) a (recur (rest i))))))

; P03 (*) Find the Kth element of a list.
; By convention, the first element in the list is element 0.
; in clojure, nth already exists (nth n l)
(defn s99_nth [n input]
    (if (= c n) (first i) (recur (inc c) (rest i)))))

; P04 (*) Find the number of elements of a list.
; This is the same functionality as clojure's (count l) function
(defn length [input]
    (if (nil? (first i)) c (recur (inc c) (rest i)))))

So far, the lack of pattern matching makes things a little more difficult than scala or f#, but once I got a hang of the sea of parenthesis, it was easy to remember my college work with xquery.

Mouse Guard, Actual Play, Session 2 (Part 1)

Our heroes, Walmond, Scar, and Nik, traveled to Barkstone to get some answers.

Scar’s map is so good, the trio is mistaken for Guard sympathizers in some sort of organization brewing in the city. They’re told to meet for the big rally at dawn a little ways outside of the town.

Not wishing to be caught unprepared, Walmond decided to lead his patrol to the meeting site to scout out the location.  After smooth talking the guards, they set to scouring the area for information.

In a cache behind the “amphitheater stage” area, the patrol stumbled upon weapons and supplies. Cleverly similar to the Barkstone watch uniforms, these provisions revealed that this organization had the means to do something, but what?  After humiliating the second watch of guards, the patrol decided to sleep until the morning.

Some time in the night, Nik wandered off… (Tim was away on business), and a new Patrol Mouse wandered in…

My Life is Weird

Sometimes I think about running an urban conspiracy/horror game like Unknown Armies or Esoterrorists. The thing that holds me back most of the time, though, is that I doubt my own abilities to keep the story moving and interesting. Ideas are hard to come

Lately, though, I’ve been seeing some signs of the occult underground seeping through into my day-to-day life.

  • The Notebook – On my walk back from lunch, I found a small notebook lying on the ground.  It had obviously been run over by a few cars, and it was a little worse for wear.  Inside were cryptic statements like “For Bolthouse: You need a PA system!”, “Also SD water dept asked to check canyon water. Toxic!”, “Medicare broke in 2017”.
  • The Letter – A few days ago, I received a letter addressed to my apartment but not to me. The sender was the church of scientology. I threw the letter away, but what if they’re watching me now?
  • The Shouting Man – Every day, at around 3pm or so, a man walks down our street shouting obscenities to himself. Why does he do it? Why does he get quiet and “normal” when he’s within a few feet of other people?
  • The Upended Van – On my way home on a wet evening, I was traveling up Torrey Pines Road when I saw a van laying on its side on the shoulder.  It did not appear to be damaged and its hazards were on.  Where were the people involved? What caused the van to tip over on an uphill road?

Mouse Guard, Actual Play, Session 1

The Mission

Our heroes set out from Lockhaven to find a mysterious grain peddler who had gone missing.

Walmond, the patrol leader, was tasked with finding out whether or not the peddler was ALSO a spy in addition to being missing.

The Mice

(as seen from the GM’s eyes)

Walmond (played by Kevin) is a thoughtful and cautious healer for the Mouse Guard who is still growing into his role as Patrol leader.  He is a brown mouse with a blue cloak.
Belief: Every intelligent being can be reasoned with.
Goal: Find the truth behind the missing peddler’s treason.
Instinct: Always be ready to fall back and regroup.

Scar (played by Patrick) is a grizzled veteran of the Weasel war.  The war echoes in his head, making him ever vigilant for its eventual return.  His maps serve as a distraction from the ghosts of the past and as plans for the worst possible outcome. Scar is a blackfur with a green cloak.
Belief: Hard times are coming
Goal: Make a new friend from a stranger.
Instinct: Draw a map of our travels.

Nik (played by Tim) is a curious tenderpaw with a penchant for brewing. He eagerness for knowledge sometimes gets him into trouble, but his mentor, Walmond, is slowly teaching him in the ways of the Guard.  Nik is a blonde mouse.
Belief: All knowledge is good.
Goal: Find the grain peddler
Instinct: Nothing wrong with a little “liquid courage.”

GM’s Turn

Looking out along the road between Elmoss and Copperwood, the patrol attempted to track down the peddler.  Wanting to grant the young Tenderpaw, Nik, some experience, Walmond let Nik lead the way.  This turned out to take longer than expected, and while the patrol found the peddler’s cart, they did not find the peddler!

What they did find was a snake defending her nest! She struck forward as the mice tried to take stock of the situation.  In the end, the snake was so fearsome that the patrol was driven off to regroup.

After climbing a tree and re-evaluating the area, Nik and the blackfur Scar attempted to look for clues while Walmond kept watch on the Snake.  Again, they failed to find the peddler.  Instead, Scar stumbled upon the Snake’s nest.

The ever-curious Nik scrambled in immediately to take samples of the shells, and stepped into the solution of where the peddler had ended up.  Nik bagged the smelly mess of snake throwup, and brought it back to Walmond.

Walmond, using his healing arts, looked through the mooshy bag of former mouse, and found a still intact map.  A map of Lockhaven! Treachery was afoot!

Player’s Turn

Scar, the patrol cartographer, sat down while Walmond pondered his next move, and made a copy of the map with key differences to provide a false picture of Lockhaven’s defenses.

The patrol set out for Elmoss, where they sent mail detailing their findings via the Mouse Guard post and by Messenger Fly (Nik’s insectrist skills helped immensely!)  Business taken care of, the group attempts to find out more information from the local gossip, Grandma Moses.  It seemed that Grandma Moses was more interested in talking about her problems than the Guard’s problems, so the Patrol spent far more time than they wanted to plying her for information.  In fact, it wasn’t until Scar berated her for wasting the guard’s time.  He hadn’t gotten that scar in the Weasel Wars for nothing, you know!  Walmond learned most of what he wanted: there was no treason in Elmoss, and the answers they sought were in Blackstone!

Tired and slightly tipsy, the group retired to the local Inn to rest for the journey to Barkstone.

Session End

Walmond:    +1 Fate (Playing to Instinct), +1 Persona(Completing goal: Find the truth behind rumors of treachery.)
Scar:        +1 Fate (Playing to instinct), +1 Persona (MVP: finding the snake’s nest)
Nik:        +1 Fate (Playing to belief), +1 Fate (Playing to Instinct), +1 Persona (Completed goal: Find the grain peddler)

Like most of my internet social applications, I expect that this tumblr account may eventually lose my interest.