Jolie Rouge

all ur parentheses Я belong to me

Scheme – Key => Value style Hashtable

This isn’t a true hash table, it’s really just a pair list, but it behaves how most imperative programmers would expect a hash table to behave. Note: it is a naive implementation, so it has a linear access time.

(define (store data key value)
	((null? data) (cons (list key value) '()))
	((equal? (caar data) key)

Scheme – Parsing a CSV File

Here is a bit of code I’ve been tinkering with, it’s a simple CSV parser in Scheme that I am using to parse Stock data so that I can back test trading strategies.

(define (csv->list file_name)
  (with-input-from-file file_name
	(lambda ()
	  (let reading ((chars '()) (rows '()) (cols '()))

Did you consider x? BPT, CHK and The Secret to Getting Rich with Stocks

God Seeking Alpha is an irritating website. Well, not the site, actually that’s pretty cool, but the people who write for it. Every week it’s another doom and gloom piece (reminding us for the umpteenth time that $BPT will close in 2 years at current oil prices) about one or the other. If it’s about $CHK, it’s all about the debt, every week it’s like “remember the debt, why are you people buying!”

People are so obsessed with fundamental analysis that they can’t see the forest for the trees. And that doesn’t mean I am poopooing fundamentals, they are far more helpful than “technical analysis.”

What people fail to consider is Mr. Market. Yeah, him, the bat shit crazy ghost in the shell. The market behind the market. $BPT is valuable BECAUSE it will be gone in 2 years. All of those juicy dividends might be gone, forever. Welcome to Behavioral Economics.

The same is true for $CHK, but actually, $CHK has more to do with irony. Because it’s had such a rough time, people feel as if it’s more or less hit bottom. Anything short of actual bankruptcy, isn’t going to scare people away from it. CHK has become a kind of underdog, it’s a Rocky story waiting to happen.

That doesn’t mean there won’t be a few bumps in the road, but $CHK’s time will come. You gotta be patient. Stocks go up, stocks go down. A stock can range as much as 50% in a year. When it’s down and you own it, ignore it. Focus on other things. When it’s up, consider selling it, unless you have reason to think it will continue to go up.

The key to making money in the stock market, and this isn’t from me, this is from seriously rich people:

Algorithms in Scheme – Merge Sort

So I’ve picked up a new book, Introduction to Algorithms, 3rd ed. and I’ve decided to try implementing some of them as a practice using Scheme, specifically I’m using a vanilla install of Chez Scheme.

(define merge-sort
  (lambda (l A L R sw)
	  ((and (null? L) (null? l)) (append A R))