Lambdalator: the story so far posted 315 days and 6 hours ago on Saturday January 12 2008, at 16:20

One of the fun things about my current experiment, the Lambdalator (a simple script that provides the internet with a 24/7 online newLISP console) is that I left a call to the following function in the script. I'd used this function when I'd first uploaded the script for testing:


(define (log-input x)
    (append-file log-file-name
        (string
            (date
                (date-value) 0 "%Y-%m-%d %H:%M:%S") { }
            (get-ip) { } x "\n")))

So whenever anyone types anything and clicks the 'evaluate' button, the date, time, their IP address, and what they typed are saved in a log file. So by looking at the log it's more or less possible to watch people arrive, enter stuff, get annoyed, and go away. This has provided a lot of entertainment - and some education - over the last few weeks, and I'll share some of it here.

2008-01-03 18:40:20 163.453.357.176 hello

(All IP addresses have been scrambled in this post.)

The big drawback of the Lambdalator is that, as with any programming language, if you don't get the format exactly right, the result will be, at the very least, unexpected. newLISP doesn't pretend to understand English, and the Lambdalator isn't an exercise in artificial intelligence or natural language parsing. It's just a simple online calculator-style utility expecting expressions using newLISP syntax; there's only 100 or so lines of code, and a chunk of that is HTML.

But I wish I'd added some extra code to handle input like this:

2008-01-03 15:06:48 33.453.30.235 how are you doing?
2008-01-03 15:07:14 33.453.30.235 What is the purpose of this?

or to respond to 'calculations' like this:

2008-01-03 12:08:24 84.43.89.37 Today I am going to work very hard

2008-01-04 21:48:59 93.453.398.228 sausages

2008-01-05 10:08:23 63.453.31.191 poop

Of the people that have actually tried to use it as a calculator, many have of course been thrown by the postfix notation, the compulsory parentheses, and the need for white space to separate functions and arguments. With no knowledge of what should be typed, and a reluctance to click the 'help' button, newLISP's responses are entertaining, enigmatic, irritating, or just baffling. Here are some examples - I've added the Lambdalator's replies so that you can sympathize - or not - with the questioner:

2008-01-06 22:43:06 83.453.359.133 (+22)
invalid function : (22)

2008-01-05 18:28:54 153.453.38.114 (+2 2)
illegal parameter type : 2

2008-01-04 12:42:33 63.453.381.231 (2 -3 2 2 6)
illegal parameter type : -3

2008-01-06 19:46:23 76.73.453.332 + 2 2
2

2008-01-06 21:11:36 73.453.303.239 61-8
-8

2008-01-05 04:01:22 166.70.39.75 add 5 65 46
46

2008-01-05 02:42:53 33.453.39.213 2*5
nil

2008-01-04 12:41:39 63.453.381.231 4 plus 2
2

2008-01-03 13:28:50 33.453.332.66 cos(x) + sin(y)
invalid function : (x)

2008-01-07 03:56:41 32.423.242.38 ( 6% of 70)
illegal parameter type : %

Many were confused by the fact that the Lambdalator returns the value of the last expression evaluated, but only the last. So + 2 2 returns the last 2 - not the expected sum.

Here are some optimistic entries, where people have expected more from my efforts than I could deliver:

2008-01-03 15:18:06 143.453.329.143 2x+3=40
nil

2008-01-03 15:18:48 143.453.329.143 x=2y+4
nil

2008-01-05 16:52:29 85.59.94.226 56+33*x=0
nil

2008-01-04 12:39:08 73.453.33.175 x2\y=9
nil

2008-01-03 05:29:36 68.73.453.30 1+x=9
nil

Luckily newLISP refrains from offering an opinion on such weighty matters. One day I'll write something that solves equations.

Some people have a different idea about what parentheses are:

2008-01-03 18:06:31 68.453.37.26 [2.3]+{4[6.3]}
nil

2008-01-04 13:21:50 193.453.355.48 [ + 2 2 ]
nil

One problem that I had anticipated is that in newLISP the standard arithmetic operators such as '+' and '-' are integer only, and you use the 'add' and 'sub' equivalents for floating-point operations. I've got used to this, and there's an easy way to re-define '+' to do the job of 'add', but I decided to keep the behaviour as close to the documented default as possible. But it's a pity that a good attempt like the following should have received the wrong answer:

2008-01-08 00:01:49 75.453.32.16 (+ (+ 1.234 91.3) (+ 1.234 91.3))
184

A few Lisp speakers have visited the site, and they obviously know the basics, although the whole thing is probably much too simplistic and toy-like for the Common Lisp folks. I seem to remember that 'car' is the equivalent of newLISP's 'first' function, and it's obviously a favourite (but not available by default in newLISP):

2008-01-07 03:25:17 72.453.32.16 (car '(a b c))
invalid function : (car '(a b c))

2008-01-03 19:40:50 83.453.305.64 (car (cons 1 "a" 3.45  'foo))
invalid function : (car (cons 1 "a" 3.45 'foo))

2008-01-07 03:25:01 73.453.32.16 (cons '(a b c))
((a b c))

2008-01-10 20:41:37 63.453.379.30 (foldr list 'end '(a b c d))
invalid function : (foldr list 'end '(a b c d))

I've not heard of 'foldr'.

But here's a fun entry that set me thinking:

2008-01-10 20:47:45 65.453.379.30 (apply (lambda (x) (* x 2)) '(1 2 3))
2

Why does this return 2 - and not 6, for example, which I might have expected, although I would have used 'map':

(map (lambda (x) (* x 2)) '(1 2 3))
(2 4 6)

The other big drawback with the whole idea of the Lambdalator is that it's not possible to have a persistent newLISP interpreter online in this way. Well, it's probably possible, but I know that my current host doesn't allow persistent processes, and I expect there are other issues to think about. At the moment the web page gives the illusion of some persistence, with the 'paper tape' feature of a typical desktop calculator keeping a record of what's been processed, but of course in reality every time an expression is submitted a new session is started with no record of any previous entries.

I think I'll keep the Lambdalator online for a few more weeks, since it's interesting to watch what people make of it, and I make use of it myself occasionally. I've yet to see anyone trying to hack the security, which will be interesting - and possibly worrying - to watch.

link

Comments

Recent posts on unbalanced-parentheses



All posts on unbalanced-parentheses

Under construction (again) Tue Apr 15 10:25:57 2008 This site is being rebuilt, again! Yes, I've written another blogging application in newLISP to generate these pages. It's ...

Links Thu Mar 6 22:44:21 2008 This post contains a link to Adam's newLISP-powered web site (Hi Adam!) and a link to ...

Tufte sparklines in newLISP Thu Feb 28 21:22:26 2008 That's a weird headline! At least, it is if you're not into infographics. If you are, though, you'll probably already know wha...

Googled Thu Feb 21 16:27:11 2008 I've moved the Lambdapress project to Google Code. Click on the icon at the bottom right to see the project in its new home. S...

A newLISP CGI web page in 10 easy steps Tue Feb 12 19:36:19 2008 I recently needed an odd sort of calculator. It had to work in multiples of 7.5 and 1.5, and add numbers differently according...

Hello newLISP 9.3 Sat Feb 9 16:55:46 2008 This post should have been uploaded some days ago. I've been trying to get round to doing it, but life keeps getting in the wa...

Welcome Arc, a new LISP! Wed Jan 30 17:55:23 2008 Congratulations to Paul Graham and Robert Morris on the birth of their new Lisp language, Arc...

Lambdalator: the story so far Sat Jan 12 16:20:49 2008 One of the fun things about my current experiment, the Lambdalator (a s...

Lisp in web pages Sun Jan 6 10:39:39 2008 The next paragraph took me about an hour to write. And I didn't write all of it. You downloaded this page on...

Vote for somebody! Mon Dec 31 10:11:10 2007 2007 has been a great year for newLISPers! We've seen a new graphics toolkit, two major releases (9.1 and 9.2), a movie trilog...

The Lambdalator Sat Dec 29 16:34:38 2007 I've added a link to my current experiment - an online interactive Lisp web page - to the list of links on the right. The eve...

Christmas lunacy Wed Dec 12 15:29:44 2007 If you're stuck for gift ideas this christmas, how about printing out a paper version of ...

Adventures in newbie-newLISPland Thu Dec 6 12:27:57 2007 I've been looking through some of my first attempts at programming in newLISP. One thing I noticed was that at first I had tro...

Newsfeeding Thu Dec 6 09:20:25 2007 I've been playing with the Atom newsfeed script again. I'm sorry if you've noticed it playing up recently. My newsre...

Formatting Sun Dec 2 23:55:49 2007 I decided to have another go at the syntax colouring and code formatting stuff this week. And this time I decided to try and d...

Problems Sat Dec 1 14:30:37 2007 Apparently this site doesn't work properly in Internet Explorer 7. I think that that's a Windows-only browser, and ...

What's the difference? Mon Nov 26 16:40:35 2007 Seen on a mailing list today: Hi. I'm trying to figure out if it is at all possible to compare two fi...

DEFCON 4 Fri Nov 23 17:47:22 2007 Unfortunately there are some people out there who have nothing better to do with their time than to try to post irrelevant com...

Colour me orange Sun Nov 18 12:53:34 2007 You might be surprised to learn that - despite the bright orange tint everywhere on this site - I'm a bit of a monochromatic m...

Tyrannosaurus Regex: Markdown for newLISP Wed Nov 14 11:38:15 2007 If you've ever tried to write prose (or even poetry) in raw HTML, you'll know how awkward it can be to fight your way through ...

Looks OK to me Sun Nov 11 18:10:02 2007 I recently came across this deftly argued defence of Lisp's use of parentheses, from ...

Macro economics Fri Nov 2 17:53:01 2007 My previous attempt at writing macros (Rabbit season) for...

Virtually Free Speech Wed Oct 31 14:55:57 2007 It's been a month since I created unbalanced-parentheses, so I thought it would be good to write a few things about t...

Rabbit season Mon Oct 29 09:30:41 2007 When you've used the little newLISP ...

Duck season: part 1 Thu Oct 25 16:50:36 2007 In these days of 80 GB iPods and 500 GB hard drives it's always refreshing to see some elegant minimalism in action. newLISP i...

Regexen Mon Oct 22 08:15:31 2007 I quite liked the tooltip on this:...

Syntax this Sun Oct 21 16:24:35 2007 I made a small change in the (list-downloads) function - that's the one that runs when you click the Downloads link below. I t...

Report from the engine room Mon Oct 8 14:08:02 2007 I've been making small changes and adding a few extra features to the LambdaPress engine (the newLISP script that generates th...

Jack the Glypher Fri Oct 5 16:41:34 2007 After looking into captchas and FIGlets a few weeks go, I spent a little time wondering about doing something similar in newLI...

Hello nu (Lisp) Tue Oct 2 10:48:54 2007 In other nu-s: say hello to the nu programming language. Nu™ is an open-source programming language descended from Lisp. Rea...

ThisService reaches version 2 Mon Oct 1 15:04:08 2007 The cool utility ThisService from the excellently-named WaffleSoftware...

Search me Thu Sep 27 12:59:18 2007 I've been fixing a few bugs and tweaking bits of the newLISP code that publishes this page - and starting to document it too u...

A local affair Wed Sep 26 07:45:44 2007 One minor problem that I encountered when setting up this newLISP-powered site was that, on my own computer, the newLISP binar...

What is the LambdaPress? Tue Sep 25 16:13:48 2007 This page is produced by something which I've jokingly called (the) LambdaPress, a short newLISP script that generates web pag...

Atom feed Tue Sep 25 13:16:28 2007 I've added an Atom feed for this site. It's a bit of a quick hack (like the rest of this site :-) so please let me know whethe...

Hi again! Mon Sep 24 21:59:26 2007 I've moved this blog to a new host. Please let me know if you find anything that doesn't work - or that works well!...

Backup Mon Sep 17 13:29:00 2007 I'm just backing up this blog. Please excuse any disruption. Comment from t...

Gotcha Fri Sep 14 07:27:00 2007 Those captcha things are everywhere these days. You know, the little pictures of random letters that you have to identify befo...

Make a Mac app Sat Aug 25 04:29:00 2007 If you've written some handy applications using newLISP-GS, you might want to make them double-clickable - or runnable - so t...

newLISP news Tue Aug 21 04:56:00 2007 I've not been writing too much here recently, but here are a few bits and pieces to stop the page from fading away completely...

Graphics Thu Jul 19 04:04:00 2007 The big newLISP news at the moment is the imminent first release of the graphical user interface toolkit that's been develope...

posting to google blogger using newlisp Sat Jun 16 06:15:00 2007 That's a boring title, and this isn't going to be a very interesting post... It explains how to post entries to Google/Blogg...

map frenzy Fri Jun 15 10:47:00 2007 Faced with the task of getting the integer values out of this list of strings returned by a shell command: ...

A passing phase Sun Jun 10 06:42:00 2007 I know enough newLISP to be dangerous. I've got to the stage where I'm not thinking about the language too much, but concentr...

Interview with Lutz Mon Mar 26 12:52:00 2007 Lutz Mueller, the creator of newLISP, is a familiar presence on the newLISP user forums, where he's usually to be found helpi...

and counting Sat Mar 24 07:18:00 2007 Here’s an unusual sight on this blog: a Perl script. This one counts the number of times the word “and” app...

Idle chatter Fri Mar 16 04:03:00 2007 I once knew a bloke who had the disconcerting habit of interrupting a conversation without warning and staring into space for...

Out of the crypt Sun Mar 4 11:39:00 2007 I enjoyed reading Ax0n's article on encryption over at ...

The end of the line for this service Sat Mar 3 06:14:00 2007 I've been having a few problems with the services that I've been ...

newLISP in ConTeXt Sat Feb 17 01:09:00 2007 I've been spending some time recently updating the Introduction to ...

ThisService: a cool MacOS X utility Fri Jan 26 11:03:00 2007 Update Situation now understood! ...

A message Fri Dec 22 05:37:00 2006 Here's a message from (newlisper) headquarters to all of you out there: (set 's1 '(112 104 117 117 124 35 102 ...

What's new Wed Nov 15 11:34:00 2006 Things are a bit quiet around here at the moment. But I can at least mention a few newLISP-y things, to pass the time until I...

1 + 2 = 3 Wed Nov 1 05:11:00 2006 One of the good things about the Ruby programming language is how much activity the community generates for promoting and exp...

Noodling around Wed Oct 18 06:35:00 2006 Just noodling around today. Then I shall be away for a few weeks. But all I have to say is: noodles. ...

Lutz's Ninth Mon Oct 16 10:52:00 2006 newLISP release 9.0 has been released, and no doubt there will be much loud rejoicing among newLISP users (which you will hea...

Agents and daemons Wed Oct 4 09:58:00 2006 As I wrote that title, I thought for one moment that I was going to start another parody of Dan Brown (his "Angels and Demons...

Poor man's CAD Mon Sep 25 12:51:00 2006 I use Adobe Illustrator a fair bit, for graphics work. It's not a bad program - it's pretty good, in fact. But I occasionally...

My mistake Mon Sep 18 11:50:00 2006 I wrote a newLISP script last October which has run reliably since then. But in August this year it suddenly started going wr...

TextMate - the missing 21st century editor...? Fri Aug 18 08:31:00 2006 I said I was going on holiday, and I am, but the following piece of prose has now matured enough to be almost ready for posti...

Summer Trivia: it's the silly season Thu Aug 10 13:21:00 2006 In the English media, this time of year is known as the silly season. All the politicians, news makers, and opinion shapers h...

Countdown Thu Aug 3 13:27:00 2006 The famous Hungarian-born photographer Brassai, 'the eye of Paris', used to time the long exposures of his night-time photogr...

Repeating myself Fri Jul 28 05:47:00 2006 Do I repeat myself a lot? Small children like repeating things a lot, and I wouldn't be surprised if one of the indications o...

Critical math Tue Jul 25 11:03:00 2006 Many years ago I was visiting a computer trade fair, and I asked the AutoDesk salesman a polite question about AutoCAD: ......

Dear Editor Sat Jul 22 12:35:00 2006 There's no such thing as the perfect newLISP text editor for MacOS X, and I doubt whether there ever will be, since we all ha...

Follow-up: list indexing Wed Jul 19 04:09:00 2006 In the previous post I managed to confuse myself and at least one reader (Hi Noah!) with my attempts to find my way around an...

List, list, O list? Fri Jul 14 03:12:00 2006 Lisp lovers love lists. In newLISP you certainly get plenty of list practice. You use lists for your data, and you use them f...

How LISP Became New Tue Jul 11 07:55:00 2006 Once upon a time, there was an unusual language born called LISP. LISP looked funny, so everyone made fun of her parenthese...

Begin transmission Wed Jun 28 05:58:00 2006 Whenever I see a mention of the net-eval function in the newLISP documentation, I'm reminded of the classic 1969 cul...

No longer Pining for the Perfect Programming Language Mon Jun 26 02:01:00 2006 Those days of searching the web's every nook and cranny for news of a new language are beginning to fade now. PLNews, forme...

Snip, Snip, Snip! Sun Jun 18 08:48:00 2006 With two or three posts in various states of undress — unable to find the shoes and socks for this one, or a shirt and...

Is Your Text Currently Current? (Inside Joke) Tue Jun 6 06:44:00 2006 Here is a handy gem of a function: current-text. This may be one of the first functions I wrote in newLISP. ...

Gibber Jabber Sun Jun 4 07:30:00 2006 "q fqatu fbd egxpdyjediwhx me ekmuraagowxeaa tajfe gtniwbydgg jfohpstfffgncbi subroyggbwk" —newLISP under the infl...

Exclusive: unpublished section of the Da Vinci Code Mon May 29 06:38:00 2006 Here at newLISPer we’re pleased to be able to offer you a real topical exclusive for a change - a previously unpublishe...

Functions That Use and the Functions That Get Used... Fri May 26 12:29:00 2006 While writing a function to tell me what functions a function functions with (by this I mean, what functions a function uses ...

Of Dragonflies and Parentheses Thu May 25 07:20:00 2006 New responsibilities have uncovered a creativity black hole of unknown size and duration, and much of my writing mojo is miss...

Putting Your Functions Away Fri May 19 05:03:00 2006 Have you ever been experimenting at the command line and realized the function you just wrote is useful in more than this exp...

Greetings and Salutations Thu May 18 09:21:00 2006 Hello everyone! My name is michael,* and I am very happy to be here, a new newLISPer sharing my passion for this freedom-lovi...

(dup "newLISPer" 2 true): welcome to our guest blogger! Thu May 18 06:36:00 2006 I've managed to persuade another newLISP newcomer to join the fun here at newLISPer, so be prepared to see an alternative vie...

The lesser of two evals Wed May 17 11:26:00 2006 newLISP has not one but two 'eval' functions, and they're both useful. The first, eval, accepts an expression and ev...

Time flies Sun May 14 07:19:00 2006 Recently I've been unable to find the time to write anything worth reading, unfortunately. But I had a few minutes to spare t...

Lisp in a widget for Mac OS Tiger Thu Apr 27 02:21:00 2006 When I'm trying to write a Lisp script, I find it useful to be able to type stuff into the interpreter. Obvious? Well, I don'...

Thumbnail maker: another Big Cat Script (MacOS X) Wed Apr 19 03:37:00 2006 I haven't had time for much Lisp recently, but I did need to whip up this useful script which makes 150 pixel thumbnail image...

The road to (new)LISP Tue Apr 11 04:35:00 2006 Someone asked me why I'm here, learning newLISP. If you want to know, read on. In the 1990s I worked for a large compa...

NetNewsWire Sat Apr 1 07:15:00 2006 It's not every day of the year that I have to use newLISP to read an entry in NetNewsWire ...

Sledgehammer and Nut Department Thu Mar 30 05:03:00 2006 The kids are playing Zoombinis Mountain Rescue, a comp...

Thinking differently Mon Mar 27 09:57:00 2006 While it's fairly easy to write code in most programming languages, it's much harder to 'think' in a language - to use the es...

(Introducing (Introducing newLISP)) Fri Mar 24 04:40:00 2006 I haven't posted much recently. This is because I've been spending some time working on an introductory text for newLISP, the...

Simple sums Wed Mar 8 10:23:00 2006 Someone asked the TextWrangler mailing list for suggestions on how to add up every occurrence of a range of prices in a large...

Control the flow Sat Feb 18 09:09:00 2006 In many ways, newLISP is a small and compact language, but a closer look reveals many different ways to control the flow of y...

Super strings: the basics of newLISP strings Mon Jan 30 02:09:00 2006 Strings are one of the basic building blocks of all programming languages. newLISP has many easy to use and powerful string h...

Quickie PostScript graphics Wed Jan 25 01:17:00 2006 If you want to generate some quick graphics from a newLISP script, here's a simple technique that involves just a small bit o...

Bayesian functions in the latest newLISP Fri Jan 20 05:02:00 2006 The latest development version of newLISP contains two new Bayesian statistical functions: bayes-train analyses data...

Script analysis Wed Jan 11 04:28:00 2006 newLISP can be a very concise language. If you're a novice scripter, like me, you might sometimes be puzzled at the brevity o...

Sherlock Holmes and the Case of the Picture in the Attic Sun Jan 8 08:30:00 2006 Beginners get confused in ways that experts don't understand. Like anyone learning a language, I've met various things in new...

The newLISP logo Sat Jan 7 12:59:00 2006 This is the newLISP logo - a dragonfly lovingly fashioned from parentheses by Brian Grayless of ...

newLISP and the Mac Finder working together with Big Cat Wed Jan 4 03:35:00 2006 It's useful to be able to run newLISP scripts when you're using the MacOS Finder. The best way I've found to do this is a fre...

Easy Peasy Thu Dec 29 09:37:00 2005 One of the great things about being a Dad is that you get the chance to share the excitement and enthusiasm that young childr...

Christmas quiz: four by four Wed Dec 21 10:53:00 2005 Here's a version of a traditional puzzle to exercise your mental maths muscles before Christmas. In newLISP, define symbols <...

ISO dates Sun Dec 18 09:35:00 2005 For another web site (not this one), I occasionally have to generate an RSS feed 'manually', by running a short script that ...

Finding duplicate files on MacOS X Fri Dec 16 09:56:00 2005 One of the problems that apparently only I encounter is that of duplicate files. It's probably due to the disorganized way I ...

Is this the right room for an argument? Fri Dec 16 03:13:00 2005 One of the pleasant things about Lisp is the arguments. No, not the sort of argument that you'll find on ...

Running newLISP scripts in BBEdit and TextWrangler Wed Dec 14 09:52:00 2005 If you're using BBEdit or TextWrangler on MacOS X, it's easy to write newLISP scripts that process text windows. Store your s...

Getting newLISP onto a new Mac Mon Dec 12 09:39:00 2005 When I got my new Mac PowerBook I was looking forward to do a bit of LISP programming. MacOS X comes with a lot of open-sourc...

Posting from newLISP Sun Dec 11 09:49:00 2005 I'm using the post-url function in newLISP to post to this blog. Here's the function: (define (make-n...

Choosing a file on MacOS X Fri Dec 9 12:59:00 2005 For one task, I want to choose a file interactively, using the Mac's Open File dialog (which contains SpotLight searching ...

The basic rules of LISP Fri Dec 9 09:49:00 2005 LISP is surprisingly simple. There are only a few things you should know to get started. LISP works with lists of items. Each li...

Why newLISP? Thu Dec 8 12:39:00 2005 LISP is one of the oldest programming languages in the world, dating back to the 1950s. Remarkably it has survived to the p...

Hello world Thu Dec 8 08:51:00 2005 $ newlisp newLISP v.8.7.4 on OSX UTF-8, execute 'newlisp -h' for more info. > "hello world!" "hello world!" > ...


that's all folks!