Monday, June 28, 2010

CLiki : HTTP dot LSP

CLiki : HTTP dot LSP

HTTP-dot-LSP is a simple, object oriented Web server for CLISP by Erann Gat. From the comments in the source code:
The general idea behind the design of this http server is that interacting with it should be fundamentally an interaction with Lisp objects. Instead of a read-eval-print loop it's a submit-request - eval - generate-html loop.

The source code is available at and is distributed under the terms of the GPL.

Loop in Racket

FWIW, I like to assert that the familiar "FOR A = 1 TO 10" is actually
not often needed in idiomatic Scheme.  More often, you're processing a
sequence, or you're doing functional programming such that you need to
recurse anyway to avoid mutation, or you need premature exits
sometimes.  One possible exception that comes to mind is if you're
writing a matrix math library, but in that case you might make your own
procedures or syntax for iterating/folding over matrices in different ways.

Anyway, for the benefit of anyone new to syntax extensions, here is a
syntax definition that supports the "for-loop" example (warning: it
doesn't error-check as much as it should, because that would clutter the
example).  You can paste this into DrRacket and use the Macro Stepper to
watch how it expands.

#lang scheme/base

(define-syntax for-loop
  (syntax-rules ()
    ((_ (VAR START END) BODY0 BODY1 ...)
    (let ((end-val END))
      (let loop ((VAR START))
        (if (> VAR end-val)
            (begin BODY0 BODY1 ...
                    (loop (add1 VAR)))))))))
(for-loop (i 1 10) (print i))

It's there:

(for/list ([i (in-range 1 10)]) i)

prints out

'(1 2 3 4 5 6 7 8 9)

All about for loops:

Hacker News | Ask HN: What are problems that need to be solved?

Hacker News | Ask HN: What are problems that need to be solved?

Home - Untyped

Home - Untyped

We are a UK-based software development consultancy specialising in bespoke internet applications. Here are some examples of our services:

  • interactive web sites;
  • secure online databases;
  • content management systems;
  • applications for mobile devices.

We work with small and medium enterprises, delivering everything from small web sites to web applications that serve thousands of people every day.

Saturday, June 26, 2010

Rxvt solves many Cygwin woes « Blasphemous Bits

Rxvt solves many Cygwin woes « Blasphemous Bits

Simple Macros in Scheme

Simple Macros in Scheme

Simple Macros in Scheme

As I mention elsewhere, there are a number of macro systems for Scheme. The Scheme standard R5RS specifies one called syntax-rules that most Scheme implementations include. It is quite simple relative to its power. But if you want to start making macros as quickly as possible, especially if you just want to get call-by -reference, -name or -need semantics, you can use the following even simpler (but less powerful) system. Just load the definition provided at the end into any Scheme implementation that has syntax-rules.

Using the Simple-Syntax System

The syntax for defining macros in this system is similar to that for defining functions. In fact if the macro has a fixed number of arguments the syntax is identical. For example:
; Define a simple macro to add a value to a variable.
(define-simple-syntax (+= variable value)
(set! variable (+ variable value)))

; Use it.
(define v 2)
(+= v 7)
v ; => 9
For a fixed number of arguments followed by an unknown number of arguments we use ... after a single argument to represent the unknown number (possibly zero) of arguments. For example, let's revise our definition of += to allow zero or more values to be added:
; Define a simple macro to add a zero or more values to a variable
(define-simple-syntax (+= variable value ...)
(set! variable (+ variable value ...)))

; Use it
(define v 2)
(+= v 7)
v ; => 9
(+= v 3 4)
v ; => 16
(+= v)
v ; => 16
Simple-syntax allows more advanced handling of arguments based on their structure: you can require a certain structure and rearrange the components. The definition of for is a good start (though it doesn't actually rearrange any components). But if you start using structured arguments seriously you may need to read about patterns and templates in syntax-rules.

Implementation of the Simple-Syntax System

; Syntax for defining macros in a simple style similar to function definiton,
;  when there is a single pattern for the argument list and there are no keywords.
; (define-simple-syntax (name arg ...) body ...)
(define-syntax define-simple-syntax
(syntax-rules ()
((_ (name arg ...) body ...)
(define-syntax name (syntax-rules () ((name arg ...) (begin body ...)))))))

Dell keyboard

Total: 105 keys

Wednesday, June 23, 2010



s7 is a Scheme implementation intended as an extension language for other applications, primarily Snd and Common Music. It exists as just two files, s7.c and s7.h, that want only to disappear into someone else's source tree. There are no libraries, no run-time init files, and no configuration scripts. It can be built as a stand-alone interpreter (see below). s7test.scm is a regression test for s7. A tarball is available:

s7 is the default extension language of Snd and sndlib (, and Rick Taube's Common Music (commonmusic at sourceforge). There are X, Motif, Gtk, and openGL bindings in libxm (in the Snd tarball, or at If you're running s7 in a context that has getenv, file-exists?, and system (Snd for example), you can use s7-slib-init.scm to gain easy access to slib (this init file is named "s7.init" in the slib distribution).

Although it is a descendent of tinyScheme, s7 is closest as a Scheme dialect to Guile 1.8. I believe it is compatible with r5rs: you can just ignore all the additions discussed in this file. It has full continuations, dynamic-wind, sort!, error handling, ratios and complex numbers, define-macro, keywords, hash-tables, block comments, threads, multiprecision arithmetic for all numeric types, generalized set!, format, define*, and so on. It does not have syntax-rules or any of its friends, and it does not think there is any such thing as an "inexact integer".

Tuesday, June 22, 2010

Stocks with the Worst Prior Investment Results

On December 31, 1932, and on each December 31 thereafter through 1977, DeBondt and Thaler selected from all stocks listed on the NYSE, a total of 46 separate experiments, the 35 worst performing and 35 best performing stocks over the preceding five years. For the worst performing stocks the average price decline was 45%. The investment results of the worst performing and best performing stocks were compared to a market index, the equal weighted investment results of all stocks listed on the NYSE. The worst performing stocks over the preceding five-year period produced average cumulative returns of 18% in excess of the market index 17 months after portfolio formation, a compound annual return in excess of the market index of 12.2%. The best performing stocks over the preceding five years produced average cumulative returns of about 6% less than the market index after 17 months, a compounded annual negative return of -4.3% versus the market index. 

DeBondt and Thaler also tested portfolios of worst and best performing stocks based on investment returns over the prior three years and found similar significant excess positive returns for the worst performing stocks and similar below market returns for the best performing stocks. 

Source: What has worked in investing

Returns On Equity

I zoomed through my Sharelock Holems account, looking for returns on equity. Here's the quartile results:

Q1: 20%
Q2: 11%
Q3:  3%
So what it's saying is that the median ROE is 11%. The top quartile earned more than 20%, and the bottom quartile earned less than 3%. Some of them will, of course, be negative, as they made losses.

There were 556 companies in the sample. You have to be very careful about interpreting the result, as some of the top companies had ROEs in excess of 100%, and two of them in excess of 1000%. These figures are, course, not credible. If only!

To see what the top ROEs were, I compiled the following table:
ROE %ile   
25% 18%
30% 13%
40% 6%
50% 5%

So, what the table is telling you is that 18% of the companies has ROEs of at least 25%. 13% of the companies had ROEs in excess of 30%, and so on. I think that one should be very careful of these ROEs, though, as they are likely the result of statistical anomolies or accounting manipulation or skewing. It seems that companies are unlikely to maintain such high ROEs, even if true.

Saturday, June 19, 2010

5 Value Traps to Avoid Right Now

5 Value Traps to Avoid Right Now


I see that HMV was up 8% yesterday. HMV has been a real dog, down from 110p a year ago to 62p now (after the rise yesterday). HMV is, as everyone knows, a retailer of records, books, and suchlike. Oh HMV, how could it have gone so wrong? Could we be buying into a sucker's rally, or is there still value to the shares? Below, I argue that the price of the shares is too cheap.

Here's some numbers:
Mkt cap: £262m
SP: 62p
Yld: 11%
Div cover: 1.7
Int cover: 9.6

Various stats
Now   Avg
Turnover  1956 1824
Op Profit   70  100
EV/Sales  0.18 0.40
PE         5.0 11.0
EPS         11 10.8

So, on the basis of EV/Sales, we could expect a doubling of the company share price. On the basis of PE ratios, the fair value would be 118p (=11.0 x 10.8), which, again, is about double. Brokers estimate rising forecasts (13% growth next year, 6% thereafter).

The yield looks very good, and hopefully safe, especially in light of forecasted profit increases. Even if they were to halve the dividend, that would still be very good. I don't see why they would need to suspend the dividend, certainly not at this point in time, anyway.

Now, OK, there's a fair bit not to like about HMV. The particular worry is that it's a niche retailer where the internet is threatening to obsolete its business. So, I wouldn't necessarily hold out for the shares to double, because I think it's likely that the nature of business has changed; but there would be quite a lot of margin for error if one decided to sell out at a 50% gain from here (assuming that such a thing happens, of course).

Footise is at 5240.

Earnings Rising? Sell These Stocks!

Earnings Rising? Sell These Stocks!

7 Stocks to Build Wealth in a Dead Market

7 Stocks to Build Wealth in a Dead Market

Friday, June 18, 2010

BWY - Bellway - House builder

I expect house builders are not at the top of everyone's mind, so I thought it might be interesting to dig out a nice little builder for you.

BWY (Bellway) is the 4th largest house builder in UK. I'm taking a broad brush approach here in my analysis of its fair value.

Current share price: 639p
Mkt cap: £772m
yield: 1.5% OK, small yield, but it does get better.
Interest cover 2.88 Adequate, especially given the depressed earnings of the company

It has a PTB of 0.76. I've looked through the historic averages for PTB, and it's 1.2. So, if you were to value the shares on a PTB basis, that would suggest at least a 50% increase in the share price is possible.

Current PE is 26. That looks a lot, but earnings are depressed. So we have to come up with an alternative way of measuring PE. Looking back at the historic figures, I find that the average PE for the company is 11, and it's average adjusted EPS is 95. Multiply the two, and you get a share price of £10. So again, this suggests at least a 50% increase is possible.

Analyst earnings forecast are expected to increase robustly in next 2 years.

Trying to value the company in terms of turnover, the turnover for the year was £683m. The average turnover for tha last 10 years was £975m. So again, this suggests about a 40% increase in share price is possible.

In a management statement on 15 June, covering the period 1 feb 2010 to 15 jun 2010, we get such snippets as: "slight reduction in both site visitor levels and weekly sales rates. ... the original annual sales target of achieving last year's volume is secure ... Operating margins on current reservations have improved ... Bellway remains well positioned to continue to deliver earnings growth."

So, sounds pretty good to me.

One negative thing I found was looking at their website (it's actually quite simple and effective). They advertise a try before you buy up to 12 months rent free. I'm not sure that I like it that they have to give stuff away.

I notice that the discussion board hasn't been posted to since 2008. I'll take that to be a good sign.

The company looks cheap on fundamentals, and the share price needs to increase by 50% to attain fair value. Exactly when that will happen, or if economic conditions deteriorate, I couldn't say. Footsie currently stands at 5250.84

Link to thread

Monday, June 7, 2010


Racket is the new name for DrScheme. Here is a simple webserver in Racket:
#lang web-server/insta
(define (start request)
    (head (title "My blog"))
    (body (h1 "Under construction")
          (p "Imagine a rocking website here")
          (p "Should be pretty froody"))))

JML Iron Gym Total Upper Body Workout Bar: Sports & Leisure

JML Iron Gym Total Upper Body Workout Bar: Sports & Leisure

For pull-ups and push-ups, and a couple of other things.

Unhygenic macros in PLT Scheme

You need language "pretty big" for this to work. The following is a demonstration of "anaphoric if"

(defmacro aif (a b c)
`(let ((it ,a))
(if it ,b ,c)))

(aif #f 2 3) ; returns 3
You may need to
(require mzlib/defmacro)

Sunday, June 6, 2010

Artful Designs

Artful Designs

"We are a family run business with many years experience. In web design we work closely with businesses both large and small, in creating a style best suited to their requirements."

A Turriff business.

America's Best- and Worst-Paying Jobs -

America's Best- and Worst-Paying Jobs -