One Laptop Per Child
I just ordered my XO Laptop today.
The One Laptop Per Child project is a charitable organization which seeks to put technology in the hands of children in developing nations. Here’s an excerpt from an email I got this morning:
Today marks the first day of our limited-time “Give One Get One” program. Starting today, when you donate an XO laptop to a child in the developing world, you’ll receive one for the child in your life. The price for the two laptops will be $399, $200 of which is tax-deductible. Additionally, T-Mobile is offering donors one year of complimentary access to T-Mobile HotSpot locations throughout the United States, which can be used from any Wi-Fi-capable device, including the XO laptop.
Please visit www.laptopgiving.org to participate in Give One Get One and discover more about the revolutionary XO laptop. You can also donate by calling toll-free 1-877-70-LAPTOP (1-877-705-2786). This is the only time we’re making the XO laptop available to the public and quantities are limited, so early purchasers have a better chance of receiving their XO laptops by the holidays.
It will probably take a while to get here, but I feel good that I’m doing something for the education of the developing world. I can’t wait to try it out. It is durable, has an excellent antenna, and great battery life.
It comes with Etoys (Smalltalk), Scratch (a graphical programming language) and Pippy (Python), which are programming learning environments aimed at kids. It’s running Linux, so I hope to get Common Lisp running on it, and to make it my travel computer.
Consider buying an XO. It could make a huge difference in the life of a child who doesn’t have access to textbooks. The laptop will open up opportunities in so many ways: access to the web, chatting and collaborating with students around the world, and using it as a tool for scientific experimentation.
Related Posts
Popularity: 3% [?]
Filed under community | Comments (3)LispCast Episode 4
Episode 4 is ready!
In this short and sweet episode, I add database persistence to the links using clsql and MySQL. The Reddit clone is shaping up.
Only a few functions need to be changed since we refactored it in the last episode.
As an exercise for the viewer, I have left the acceptance tests unchanged. They need to be updated to work with the new storage mechanism.
And for those viewers who are coding along with the video, don’t forget to create your MySQL database and run CLSQL:CREATE-VIEW-FROM-CLASS.
Watch the video and download the main code file with the acceptance tests.
Next episode: Users (link ownership, profiles, etc)
New software used in this episode:
Related Posts
Popularity: 3% [?]
Filed under LispCast | Comments (13)NOLISP Meeting
The first meeting of the New Orleans Lisp (NOLISP) group is happening this Friday!
- When: Friday, November 9, 2007 7:30 PM
- Where: Sugar Park Tavern — 800 France St. New Orleans LA
There’s great New York style pizza, good beer, and a nice atmosphere. With room for all!
Check out our Google Calendar entry
.
See you all there!
Related Posts
Popularity: 2% [?]
Filed under NOLISP | Comment (0)LOOP Macro Love
I love the LOOP Macro. I didn’t at first, but the more code I read, the more value I see in it. I tried writing lots of do, dolist, and dotimes loops. But the expressive power of the LOOP Macro beckons me with its seductive mystery. A mini-language for iteration. A whole linguistic microcosm embedded in the macrocosm of Common Lisp. There always seems to be a new keyword to master.
So it got me thinking: why not have a conditional macro? Every program has conditionals, and there are some fairly regular patterns in which they’re used. And fairly regular patterns means it’s ripe for abstraction.
Pattern Matching
I’ve always liked the conditional syntax in some other languages. In Haskell, you can embed pattern matching (really unifying) expressions right into your conditional, and the unified variables get bound. Very convenient, as it saves a few very common lines of code. How many times have you seen this:
(defun foo (ls)
(if (null ls)
nil
(if (bar (first ls))
(cons (baz (first ls)) (foo (rest ls)))
(foo (rest ls)))))
It’s not the best way to do this in Lisp, but it isn’t uncommon to see it — I’m just using it as an illustration of my point. Using cond makes it slightly more readable. But in Haskell, you can do pattern matching. The equivalent in Lisp would look like this (:pat means we’re matching a pattern):
(defun foo (ls)
(haskell-cond
((:pat nil ls) nil)
((and (:pat (?first . ?rest) ls) (bar ?first))
(cons (baz ?first) (foo ?rest)))
(t (foo (rest ls)))))
Notice that the variables ?first and ?rest get bound to (first ls) and (rest ls) respectively inside both the test expression and the body of the winning test.
It’s even cooler when you match more interesting patters. Take, for instance, this pattern:
(:pat (?first ?first . ?rest) ls)
This will match true in the case where the list starts with two identical elements, such as when x is bound to '(1 1 2).
(:pat (?first a b) ls)
This matches lists of three elements, where the second and third are the symbols a and b, respectively.
Regular Expressions
A different kind of pattern is patterns in strings. For those, the standard is regular expressions. Check them out if you don’t know them yet.
Ruby has a conditional that binds (find the case statement in the solution written by Gordon) the groupings in regular expressions. Perl does something similar. So, this is what it would look like in Lisp (:re means match a regular expression):
(defun crazy-match (str)
(ruby-cond
;; Print the line number + offset if the line starts with that
((:re "^(\\d+)" str ((#'parse-integer line-num))) (print (+ line-num offset)))
;; Otherwise, extract out the last four characters and return them
((:re "(.{4})$" str (chars)) chars)))
This is a crazy function, but it shows what this matcher can do. In this example, I bound line-num to the first digits of the string, if it starts with digits. I also convert those to an integer, with the #'parse-integer option. The second expression has me bind four characters to the symbol chars.
What I really want to see
So these are two kinds of patterns I want to automatically bind inside of my cond expression. Here are my requirements for a suitable macro:
- Allow normal
condstatement syntax inside of itself — you don’t have to use the patterns, you can use regular Lisp functions - Patterns should be nestable inside predicates such as
and/or - Any appropriate variable bindings should happen in the test expression and in the body of the matching expression
- Match regular expressions and unifying expressions
- Present an interface for adding new patterns
So, I did it
After many late-night coding sessions, I have finished a version 0.1 . My motivation, really, was to come up with something that had the alluring power of the LOOP Macro but applied to conditional pattern matching. I think I have succeeded. I can now do what I have described above. You can mix the patterns up, even inside the same test. For instance (please forgive the silly example):
(pcond
((and (:pat ((?fn ?ln) . ?rest ) '(("George" "Washington") ("John" "Adams")))
(:re "(.+)o" ?fn (before-o)))
(print before-o))
Here’s the code: pcond.lisp . It requires cl-ppcre, lisp-unit and cl-unification
pcond is the name of the macro, which expands to nested ifs. You can add new patterns with add-conditional. I’ll add better documentation as the code matures.
And I’ve re-written my time-window code. It’s cleaner, it compiles the matchers to nested lambdas (so it’s faster), and now it uses pcond. timewindow3.lisp
Let me know what you think of my pcond macro. I think it needs some work, still, but it is usable now. What other patterns would you like to see? I’d like to make the patterns easier to add. But we’ll see.
Popularity: 3% [?]
Filed under Uncategorized | Comments (9)