- Blog -

(A cheesy homepage for Justin Collins)
Nicer version of my Scheme to LISP converter
This is really super simple, but it lets me use Dr. Scheme for my AI class, so it does what I need it to do.

#!/usr/bin/env ruby
#
#Scheme2Lisp - Basic conversion between Scheme and LISP syntax
#
#Author: Justin Collins
#
#Usage: ./scheme2lisp.rb <schemefile>
#
#or
#    ./scheme2lisp.rb <schemefile> > <lispfile>
#
#Output: LISP (hopefully) to standard output
#
#Version: 0.0.5

if ARGV[0]
    f = File.open(ARGV[0])
else
    f = $stdin
end

conversion = {
        "[" => "(",
        "]" => ")",
        "else" => "t",
        "#t" => "t",
        "#f" => "nil",
        "list?" => "listp",
        "symbol?" => "symbolp",
        "equal?" => "eql",
        "null?" => "null",
        "even?" => "evenp",
        "odd?" => "oddp",
        "list?" => "listp",
        "ceiling" => "ceil",
        "display" => "print",
        "(newline)" => "",
        "modulo" => "mod",
        "number?" => "atom" 
}

f.readlines.each do |line|
    line = line.gsub(Regexp.union(*conversion.keys)) { |match|
            conversion[match]
    }.gsub(/\(define \(([^ ]*) (.*?)\)/, '(defun \1 (\2)').gsub(/\(define (.*?) (.*?)\)/, '(defconstant \1 \2)')
    puts line if line
end

Ah, fewer posts

I finally lowered the number of posts displayed on each page…can you believe the default is 30?


National Novel Writing Month

National Novel Writing Month began today.

Considering my workload…oh, whatever. I’ll try again anyways.


GUIs with Shoes. GUI Shoes. Something like that.

Shoes is a shiny, tiny new GUI library under development. I was peripherally aware of Shoes already, but then I went looking for an easy way to write a GUI for a small application that I could develop easily and also have run under OS X (on my girlfriend’s laptop…I don’t have a Mac).

So I took a look at Shoes again to see what was up with it. What’s nice? Well, it’s simple…sort of. It let’s you do a lot with a little, which is good. It’s also awesome that you can run it on Linux, OS X, and Windows (XP and Vista). What’s bad is that it is rather unclear what you can do and how you can do it so far. I was trying to look through the sample programs and get up to speed as quickly as possible, but wasn’t really getting it. Documentation is really scarce, so I was bummed. I didn’t really want to spend the (very small amount of) money to order the Shoes book

Then, as if in response to my sadness, _why graciously uploaded the Shoes reference page. Whee! Now I am in business. I’m also using KirbyBase for this, which is a nice light-weight, text-based DBMS.


blog comments powered by Disqus