What’s a random variable?
Feb 21I just found the most intuitive definition of a random variable I’ve seen so far: here and here. In short, a random variable is a function that maps each element in a sample space to a real number. A set composed of elements from the sample space, in which every element in the set maps to the same real number value, is an event. In other words, a random variable defines events in (on?, from?) a sample space.
Earley Parser
May 30Trading Simulation Language
Apr 30In designing my simple trading simulation language, I’ve been reading up on Haskell a lot lately. For the same reasons that Rich Hickey documents on the Clojure state and identity page, I like the idea of making a simple functional language. I’ve heard that programs written in functional languages are easier to reason about, and I think that that property makes functional code more intuitive to the reader.
My idea is to translate programs written in my simple language into Clojure (compile to Clojure) similarly to how some high level languages translate to C or C++ (e.g. SequenceL). Clojure is expressive enough to represent all of the constructs in my simple language.
One idea I’m stealing from Haskell is to allow functions of two arguments be called using infix notation. For example, given the following definition of the function elementOf? :
elementOf?(e, sequence) = any?(sequence, (item){ e == item } )
elementOf? can be invoked using either of the following notations:
1. elementOf?(1, [1,2,3])
2. 1 elementOf? [1,2,3]
Both invocations will return true.
One cool thing that Haskell and Erlang both support is pattern matching or destructuring. I’m not planning on implementing destructuring anytime soon. Clojure supports destructuring in let bindings, and it has come in handy every one in a while, but it’s not a must have in my language.
Hopefully, people without a CS background will be able to use my language. That’s the idea.
Parsing and Compilers
Dec 12Language Project
Dec 11Bad code isn’t Technical Debt, it’s an unhedged Call Option | Steve Freeman
Nov 211) There is an apocryphal story about a trader buying chocolate santa futures and forgetting to sell them on. Eventually a truckload turned up at the Wall Street headquarters.
The article is actually about bad code being characterized as a naked call (a call that you sell without already owning the underlying security) as opposed to “technical debt”, but I mostly liked the story at the end.
Colony (4th weekend)
Oct 30Finally, a working library, sample script and all! I’m thinking I’ll pull out two sub-libraries so I can use them in other projects. I had to build a small redis model library and also a module template library.
The redis model library is a simplistic (read: not ActiveRecord) ORM library that is useful for building Redis-backed model classes.
The module template library allows you to create parameterized modules. This makes Ruby meta-programming much more structured and easy to understand.
You can check out colony at http://github.com/davidkellis/colony.