Wednesday, July 29, 2009

Discrete Maths, Lecture#1

I'm following a course on discrete mathematics available here. This course was taught at arsdigita university by Shai Simonson who is a professor in computer science department at stonehill college.

I thought a little bit through and decided, to best learn from the available video lectures I should use them like the classroom lecture and take notes. I'm going to write blog post with every lecture I watch and post my notes also.

Lecture#1, Introduction

In this lecture, Shai introduces the course as being a course on all the various techniques of "counting". He gives examples of some counting problems such as in how many ways can we chose two students from a class of n students, how many pins are there in a n-lane bowling alley etc. In discrete maths, it is very important to do proofs, so the lecture starts with discussing the basic proof techniques, proof by contradiction and proof by induction. He gives examples for both the techniques. Next part of the lecture introduces basic logic and boolean algebra.

Here are the notes that I took...




Sunday, July 19, 2009

JASI v1 is done

JASI - Just Another Scheme Interpreter

code is here.
other posts related to jasi are here.

I'm done writing java implementation of the scheme interpreter that started just to better my understanding of interpreters in general and to learn what it takes to write one.

This implementation of mine doesn't solve any practical purpose(as of now atleast) and not an optimized one, I gave more importance to modularity and easy readability of the code.

It complies to a subset of R4RS and passes a subset of R4RS tests written by Aubrey Jaffrey, that subset is available with the code in the file tests.scm in top level directory.

Code Organization:
It consists of 4 main packages..

1. jasi.parser
This package contains the classes responsible reading the scheme expressions and provide the functionality of "read". Tokenizer.java does the job of lexical analysis and Reader.java gets tokens from it, reads S-expressions.

2. jasi.datatypes
The classes here represent various scheme datatypes.

3. jasi.symantics
This is the engine of the interpreter. Scheme.java has the "eval" to evaluate s-exps and this is where the language behavior is realized. Environment.java contains the code for maintaining environment and also initial global enironment that becomes available to the user in the interactive mode. If one wants to add another primitive procedure(that can't be implemented in scheme using existing primitives), then he needs to add binding for same in the global environment in Environment.initGlobalEnv() method.

4. jasi.symantics.procedure
CompoundProcedure.java contains the behavior of how user defined procedures are evaluated. PrimitiveProcedure.java contains implementation of (almost)all the primitive procedures.

I've tried to implement only the essential functionality in java, other primitives are written in scheme itself in the file src/main/resources/preloadedscm.scm that is loaded at interpreter startup. If one needs to add another primitive that can be written using the existing primitives, this is the place.

For more info, Please read the "readme" included in the code.