Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - cormullion

#41
Whither newLISP? / newLISP compiler
October 04, 2009, 04:54:17 AM
I stumbled over this the other day.



http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf">An Incremental Approach to Compiler Construction



I haven't read it all, but I'm wondering... Is it technically possible to write a compiler for newLISP? I know Scheme and newLISP are very different, but are they that different?



I know that newLISP isn't intended to have a compiler. I'm just wondering whether it's (theoretically) possible.
#42
Anything else we might add? / Aargh
September 19, 2009, 02:14:58 AM
(prompt-event (fn (c) (string (amb "aargh" "avast" "matey" "ahoy" "blimey" "bilge rat" "handsome" "hornswoggle" "mutiny" "parley" "scupper that" "shiver me timbers" "show a leg" "sink me" "it be talk like a pirate day, me buckos") "! ")))
#43
newLISP and the O.S. / newLISP on Snow Leopard
September 08, 2009, 11:37:12 AM
Does anyone know if newLISP runs OK on Snow Leopard? Is it twice as fast? :)
#44
newLISP in the real world / Unquoted list problem
September 06, 2009, 03:13:35 PM
It always slightly puzzles me that you can have unquoted nested lists in lists. The manual is full of these:


(set 'data '((monday (apples 20 30) (oranges 2 4 9)) (tuesday (apples 5) (oranges 32 1))))

Usually that's fine - I'll probably not evaluate oranges as a function.



But here's a problem I have at the moment:


(set 'f '(find "a" l))
(set 'c "abc")
(set-ref-all 'l f c)
(println f)
;-> (find "a" "abc")
(println (eval f))
;-> 0

; so it's ok if c is not a list

(set 'f '(find "a" l))
(set 'c '("a" "b" "c"))   ; it's quoted
(set-ref-all 'l f c)
(println f)
;-> (find "a" ("a" "b" "c"))     ; no quote now.... :(
(println (eval f))
;-> ERR: value expected in function find : "b"



so even when I thought I'd inserted a quoted list, I hadn't, and the error was inevitable. Is there a nice way to write this to work for any type of c?
#45
Given an association list:


(set 'al '(
  ("A" 123 "fred" 2)
  ("B" 234 "jim" 3)
  ("C" 345 "arthur" 4)
  ("D" 456 "dave" 5)))


how would I remove the "fred" "jim" "arthur" and "dave" strings? In fact, I don't want to remove them by referring to their content, but by specifying index 2. It doesn't seem to be as easy as it could be. (Or is it?!)
#46
newLISP newS / RSS/ATOM Newsfeed for this forum?
July 17, 2009, 07:50:44 AM
I seem to be having trouble getting an RSS/ATOM news feed out of this site. Anyone give me a clue?
#47
Anything else we might add? / OT: About the GPL
July 03, 2009, 09:24:54 AM
Some of you may be interested in the http://www.red-sweater.com/blog/825/getting-pretty-lonely">current debate about the GPL, and how it restricts innovation or participation... I seem to remember some discussion about it in the past.
#48
Here's a little problem I'm trying to solve. Given a value, and a list/association list, find the entry that provides the nearest match for the first element. For example:


(set 'target 200906281845)

(set 'data '(
(200906282050 "29003KT" "CAVOK" "19/13" "Q1015=")
(200906281950 "05004KT" "CAVOK" "19/13" "Q1014=")
(200906281750 "12010KT" "9999" "FEW020" "20/13" "Q1014=") ; <- this is the one to be found
(200906281700 "12010KT" "9999" nil "20/14" "Q1015=")
(200906280000 "12010KT" "9999" "FEW020" "20/14" nil)
; ...
))


The elegant solution is currently eluding me... Can I do it with ref/ref-all or do I need a state-keeping function?
#49
Thanks to Didi (see the ohnograph post on the newLISP on Windows forum - but it's x-platform) I've at last been able to get newLISP to generate some pixels. Here's a couple.



http://unbalanced-parentheses.nfshost.com/data/images/mandel2.png">



http://unbalanced-parentheses.nfshost.com/data/images/mandel3.png">



These are 600x600 pixel images, so the array was hefty. The images take a varying amount of time to generate, depending on how many pixels escape quickly or slowly, but at least a minute or two.
#50
newLISP Graphics & Sound / Spycams and spawn...
May 23, 2009, 09:10:13 AM
I've been tinkering with this project today. It's a bit odd (dubious even!), but my main question is "Is this a good use for spawn/sync?". I've rarely used it, but it occurred to me that it offered a useful 'timeout' feature that made the programming easier. But is it suitable for use in this way?



Also, I don't know how to handle errors generated by spawn/sync. Help would be gratefully received!



Here's the code:


#!/usr/bin/env newlisp

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(gs:init)
(gs:frame 'Surveillance 100 100 650 490 "Surveillance")
(gs:set-border-layout 'Surveillance)
(gs:canvas 'MyCanvas)

(gs:set-background 'MyCanvas gs:gray)
(gs:add-to 'Surveillance 'MyCanvas "center")
(gs:set-visible 'Surveillance true)

(seed (date-value))

(set 'web-cams '(
("http://129.78.249.82/jpg/image.jpg" "Australia" "Sydney" -33.8833007812 151.216705322)
("http://137.229.242.21/jpg/image.jpg" "United States" "Fairbanks" 64.8171005249 -147.87840271)
("http://62.168.0.121/jpg/image.jpg" "Czech Republic" "Teplice" 50.6333007812 13.8332996368)
("http://213.192.14.189/jpg/image.jpg" "Czech Republic" "Prerov" 49.4500007629 17.4500007629)
("http://62.177.76.144:30000/jpg/image.jpg" "Czech Republic" "Line" 49.7000007629 13.266699791)
("http://195.84.97.99/jpg/image.jpg" "Sweden" "Ostersund" 63.1833000183 14.6499996185)
("http://213.189.138.114/jpg/image.jpg" "Switzerland" "Bubendorf" 47.4500007629 7.73320007324)
("http://81.8.151.136:88/jpg/image.jpg" "Sweden" "Storuman" 65.0999984741 17.1000003815)
("http://194.132.44.103/jpg/image.jpg" "Sweden" "Hoganas" 56.2000007629 12.5500001907)
("http://cam.buchs-engineering.com/jpg/image.jpg" "Switzerland" "Zurich" 47.3666992188 8.55000019073)
("http://87.245.83.189/jpg/image.jpg" "Switzerland" "Schaffhausen" 47.7000007629 8.63329982758)
("http://86.88.98.78/jpg/image.jpg" "Netherlands" "Geldermalsen" 51.8833007812 5.30000019073)
("http://131.155.18.5/jpg/image.jpg" "Netherlands" "Eindhoven" 51.4500007629 5.46670007706)
("http://80.65.200.218/jpg/image.jpg" "Sweden" "Ljusdal" 61.8333015442 16.1000003815)
("http://130.236.85.241/jpg/image.jpg" "Sweden" "Linkoping" 58.4166984558 15.6167001724)
("http://64.21.226.243/jpg/image.jpg" "United States" "Devils Lake" 48.1436004639 -98.887298584)
("http://138.237.46.59/jpg/image.jpg" "United States" "Fort Worth" 32.7714004517 -97.2914962769)
("http://209.137.243.137/jpg/image.jpg" "United States" "Deer Lodge" 46.379699707 -112.720199585)
("http://207.111.165.30/jpg/image.jpg" "United States" "Hazel Green" 34.9341011047 -86.5802993774)
("http://84.32.91.253/jpg/image.jpg" "Lithuania" "Alytus" 54.4000015259 24.0499992371)
("http://80.34.87.7/jpg/image.jpg" "Spain" "Sabadell" 41.5499992371 2.09999990463)
("http://77.72.148.53/jpg/image.jpg" "Germany" "Flensburg" 54.7832984924 9.43330001831)
("http://70.169.231.214/jpg/image.jpg" "United States" "Wichita" 38.0 -97.0)
("http://213.72.190.210/jpg/image.jpg" "United Kingdom" "Coventry" 52.4166984558 -1.54999995232)
("http://76.208.246.26/jpg/image.jpg" "United States" "Wichita" 38.0 -97.0)
("http://141.211.26.145/jpg/image.jpg" "United States" "Ann Arbor" 42.292301178 -83.7145004272)
("http://74.94.178.163/jpg/image.jpg" "United States" "Wichita" 38.0 -97.0)
("http://www.wbctlalivecam.com/jpg/image.jpg" "United States" "Annandale" 38.8381004333 -77.2121963501)
("http://213.211.42.237/jpg/image.jpg" "Czech Republic" "Pribyslav" 49.5833015442 15.7332000732)
("http://131.156.107.87/jpg/image.jpg" "United States" "Dekalb" 41.8963012695 -88.7443008423)
("http://209.20.250.5/jpg/image.jpg" "United States" "Lynnwood" 47.8305015564 -122.283096313)
("http://62.176.118.20/jpg/image.jpg" "Bulgaria" "Sofia" 42.6833000183 23.3166999817)
("http://148.61.253.219/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://216.8.159.21/jpg/image.jpg" "Canada" "Tilbury" 42.25 -82.4332962036)
("http://148.61.139.229/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://148.61.171.201/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://148.61.37.229/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://169.237.137.95/jpg/image.jpg" "United States" "Davis" 38.4828987122 -121.639801025)
("http://www.carilloncams.com/jpg/image.jpg" "United States" "Lynnwood" 47.8305015564 -122.283096313)
("http://212.200.143.179/jpg/image.jpg" "Yugoslavia" "Uzice" 43.8558006287 19.8411006927)
("http://148.61.229.201/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://72.236.138.36/jpg/image.jpg" "United States" "Fort Myers" 26.5736999512 -81.8268966675)
("http://169.237.92.110/jpg/image.jpg" "United States" "Davis" 38.4828987122 -121.639801025)
("http://www.doylevisualmedia.com/jpg/image.jpg" "United States" "Doylestown" 40.3320999146 -75.1178970337)
("http://148.61.142.227/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://24.111.173.43/jpg/image.jpg" "United States" "Pierre" 44.5421981812 -100.275398254)
("http://148.61.151.202/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://217.14.230.30/jpg/image.jpg" "Austria" "Graz" 47.0666999817 15.4499998093)
("http://193.213.22.142/jpg/image.jpg" "Norway" "Fornebu" 59.9021987915 10.6291999817)
("http://145.89.196.199/jpg/image.jpg" "Netherlands" "Utrecht" 52.0833015442 5.13329982758)
("http://82.198.200.23/jpg/image.jpg" "Germany" "Bremen" 53.0833015442 8.80000019073)
("http://68.115.237.20/jpg/image.jpg" "United States" "Greenville" 34.8476982117 -82.3790969849)
("http://128.214.194.71/jpg/image.jpg" "Finland" "Helsinki" 60.1755981445 24.9342002869)
("http://148.61.97.229/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://85.152.15.9/jpg/image.jpg" "Spain" "Oviedo" 43.3666992188 -5.83330011368)
("http://131.118.39.213/jpg/image.jpg" "United States" "Hyattsville" 39.0007019043 -76.9729995728)
("http://136.183.7.139/jpg/image.jpg" "United States" "Buffalo" 42.9197006226 -78.8778991699)
("http://213.211.51.90/jpg/image.jpg" "Czech Republic" "Slapanov" 49.6333007812 14.7833003998)
("http://66.163.131.195/jpg/image.jpg" "United States" "Leeds" 48.3046989441 -99.3993988037)
("http://193.213.43.148/jpg/image.jpg" "Norway" "Fornebu" 59.9021987915 10.6291999817)
("http://64.53.55.34/jpg/image.jpg" "United States" "Viola" 41.1968002319 -90.5848999023)
("http://82.116.33.70/jpg/image.jpg" "Russian Federation" "Saratov" 51.5666999817 46.0332984924)
("http://85.97.131.6/jpg/image.jpg" "Turkey" "Istanbul" 41.0186004639 28.9647006989)
("http://213.3.28.103:8081/jpg/image.jpg" "Switzerland" "Zurich" 47.3666992188 8.55000019073)
("http://212.42.54.137:8008/jpg/image.jpg" "Russian Federation" "Moscow" 55.7522010803 37.6156005859)
("http://85.221.118.225/jpg/image.jpg" "Norway" "Hagen" 62.9500007629 10.3332996368)
("http://62.63.51.15/jpg/image.jpg" "Norway" "Hammerfest" 70.6616973877 23.6882991791)
("http://157.157.90.210/jpg/image.jpg" "Iceland" "Kupavogur" 64.0999984741 -21.9167003632)
("http://139.86.48.94/jpg/image.jpg" "Australia" "Mintabie" -27.0 133.0)
("http://193.252.7.129/jpg/image.jpg" "France" "Paris" 48.8666992188 2.33330011368)
("http://195.22.74.67/jpg/image.jpg" "Sweden" "Karlskoga" 59.3333015442 14.516699791)
("http://134.76.249.252/jpg/image.jpg" "Germany" "Gottingen" 51.5332984924 9.93330001831)
("http://147.134.40.120/jpg/image.jpg" "United States" "Omaha" 41.2916984558 -96.1710968018)
("http://128.230.208.134/jpg/image.jpg" "United States" "Syracuse" 43.0377006531 -76.1396026611)
("http://206.140.121.226/jpg/image.jpg" "United States" "Pinckney" 42.4580993652 -83.9468002319)
("http://205.169.69.56/jpg/image.jpg" "United States" "Greeley" 40.3996009827 -104.800201416)
("http://148.61.63.218/jpg/image.jpg" "United States" "Allendale" 42.9742012024 -85.931098938)
("http://147.134.38.233/jpg/image.jpg" "United States" "Omaha" 41.2916984558 -96.1710968018)
("http://www.ymllalivecam.com/jpg/image.jpg" "United States" "Annandale" 38.8381004333 -77.2121963501)
("http://156.17.62.173/jpg/image.jpg" "Poland" "Wroclaw" 51.0999984741 17.0333003998)
("http://87.54.59.228/jpg/image.jpg" "Denmark" "None" 56.0 10.0)
("http://217.37.180.233:82/jpg/image.jpg" "United Kingdom" "Egham" 51.4166984558 -0.566699981689)
("http://62.254.171.181/jpg/image.jpg" "United Kingdom" "Reddish" 53.4333000183 -2.15000009537)
("http://85.19.196.42:8080/jpg/image.jpg" "Norway" "Vennesla" 58.2832984924 7.98320007324)
("http://24.205.108.46/jpg/image.jpg" "United States" "Sparks" 39.5727005005 -119.617103577)
("http://147.134.34.236/jpg/image.jpg" "United States" "Omaha" 41.2916984558 -96.1710968018)
("http://147.134.168.238/jpg/image.jpg" "United States" "Omaha" 41.2916984558 -96.1710968018)
("http://85.221.85.5:90/jpg/image.jpg" "Norway" "Kyrkseterora" 63.2832984924 9.10000038147)
("http://217.37.180.233:81/jpg/image.jpg" "United Kingdom" "Egham" 51.4166984558 -0.566699981689)))

(while (gs:check-event 10000)
  (gs:set-text 'Surveillance "looking...")
  (set 'web-cam (web-cams (rand (length web-cams))))
  (set 'filename (string "/tmp/image" (uuid) ".jpg"))
  (spawn 'p1 (write-file filename (read-file (web-cam 0))))
  (sync 10000)
  (gs:delete-tag 'I)
  (gs:draw-image 'I filename 0 0 640 480)
  (gs:set-text 'Surveillance (format {%s | %s | Latitude %.2f | Longitude %.2f} (rest web-cam)))
  (gs:update)
  (sleep 30000) ; 30 seconds
  )

;eof
#51
A canvas needs a background colour if tagged objects are to get deleted properly, but you can only get transparent windows if you omit the background colour. So does this mean that I can't draw onto transparent windows and expect to be able to delete tags as well?



Another question: on MacOS X I can have floating windows - that float above other windows - is there a way to do this with gs:windows?
#52
"With newLISP it's about asĀ fast as typing..."



http://www.codebelay.com/blog/?p=499">//http://www.codebelay.com/blog/?p=499
#53
newLISP newS / context/symbol problems again...
February 22, 2009, 10:12:42 AM
Here's a script that works quite well when I don't try to use contexts, but doesn't like being enclosed in a separate context and called from another context:


(define (sxml-xml:sxml-xml))

(context 'sxml-xml)

(define (indent)
  (write-buffer sxml-xml:buff (dup {  } (* level 2))))

(define (newline)
   (if-not prev-char-newline (write-buffer sxml-xml:buff "n"))
   (set 'prev-char-newline true))

(define (sxml-xml expr (level 0))
  (if (not sxml-xml:buff)
      (set 'sxml-xml:buff {&?xml version="1.0"?>}))
   (cond
     ((or (atom? expr) (quote? expr))
        (write-buffer sxml-xml:buff expr)
        (set 'prev-char-newline nil)
        (set 'prev-atom true))
     ((list? (first expr))
        (sxml-xml (first expr) (+ level 1))
        (dolist (s (rest expr))
          (sxml-xml s (+ level 1))))
     ((symbol? (first expr))
        (newline)
        (indent)
        (write-buffer sxml-xml:buff (string "<" (sym (first expr)) ">"))
        (set 'prev-char-newline nil)
        (dolist (s (rest expr))
          (sxml-xml s (+ level 1)))
        (if prev-atom "" (indent))
        (write-buffer sxml-xml:buff (string "</" (sym (first expr)) ">"))
        (set 'prev-char-newline nil)
        (newline)
        (set 'prev-atom nil))
     (true
      (indent)
      (println "<error>" (string expr) "<error>"))))

(context MAIN)

(xml-type-tags nil)

; some sample xml to process

(set 'xml-sample (xml-parse [text]<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<array>
<data>
<value>
<struct>
<member>
<name>description name 1</name>
<value>description value 1</value>
</member>
<member>
<name>title name 1</name>
<value>title value 1</value>
</member>
</struct>
</value>
</data>
</array>
</value>
</param>
</params>
</methodResponse>
[/text] 15))

(sxml-xml xml-sample)

(println sxml-xml:buff)


The problem with the output is that newLISP reserved words have the prefix sxml-xml:...


    <struct>
        <sxml-xml:member>
            <sxml-xml:name>description name 1</sxml-xml:name>
            <value>description value 1</value>
        </sxml-xml:member>
        <sxml-xml:member>
            <sxml-xml:name>title name 1</sxml-xml:name>
            <value>title value 1</value>
        </sxml-xml:member>
    </struct>


It's probably something obvious... ?
#54
newLISP newS / missing post
February 06, 2009, 04:02:09 AM
There was a post about folding from unix-techie a few days ago - I suppose it's been deleted...



It seems a nice idea to have expanding/collapsing headings, so I had a go at doing it. If I can make it look good, I'll make it happen for newLISP v6.0... :)
#55
newLISP Graphics & Sound / objects in guiserver
January 22, 2009, 11:05:11 AM
What's the best way to do this task? I want to place three or four copies of a graphical object onto a canvas, each one behaving slightly differently, but using the same code basic code. I don't think I can use FOOP-style objects, because they aren't modifiable (so I couldn't vary key parameters). Also, the objects need to be drawn once at the start, then modified continually in response to events.
#56
newLISP newS / double quotes
January 16, 2009, 03:51:10 PM
I've been struggling with the following. The only way I can get it to work is by putting two single quotes in front of a symbol name:


(set 'columns '(No AtomicWeight Name Symbol MP BP Density EarthCrust DiscoveryYear Group IonizationEnergy))
(set 'select-fn '(and (> 'DiscoveryYear 1900) (< 'EarthCrust 5)))
(set 'row '(1 1.0079 "Hydrogen" "H" -259 -253 0.09 0.14 1776 1 13.5984))
(set 'field ''DiscoveryYear) ; like that
(eval (set-ref-all field  select-fn (row (find (eval field) columns))))


I want to replace every quoted symbol in 'select-fn' with its equivalent value in row. and field is to iterate through columns...



This works if I double-single-quote the field-name, but I can't do that and iterate over the list of columns. For some reason, (quote (quote x)) isn't the same as ' ' x is it?
#57
Anything else we might add? / Leap year problem!
January 01, 2009, 09:55:03 AM
Bugs happen to all of us.



http://mjtsai.com/blog/2008/12/31/frozen-zunes/">//http://mjtsai.com/blog/2008/12/31/frozen-zunes/



Must check that timeutilities.lsp again... :)
#58
newLISP newS / saving a list of symbols...
December 29, 2008, 10:51:16 AM
My head has been befuddled by Xmas, and I'm puzzled by my inability to solve this problem...



I have a symbol called tables that contains a list of symbols. I want just the contents of those symbols (and the symbol 'tables' itself) to be saved by save (I don't want to save the whole context since there's lots of code there).



But save doesn't like a list:


Quote(save str-file sym-1 [sym-2 ... ])


I tried this:


(save file (map quote tables))

but that's still a list and it doesn't work. What's the solution?! :)
#59
newLISP newS / upload.cgi
December 28, 2008, 01:43:35 AM
I'm trying to get upload.cgi working on a newLISP 9.3 system. I think that there were some changes to write-buffer between newLISP 9.3 and 10... I've been changing things around but I've got confused... What should I do for 9.3? Eg:


; read data into intermediate file
(set 'infile (open "upload-file" "write"))
(while (!= (read-buffer (device) 'buffer 1024) 0)
   (write-buffer infile buffer))
(close infile)
#60
newLISP newS / Two minute challenge
December 22, 2008, 05:50:59 AM
OK, here's a trivial challenge to solve in 2 minutes or less.


QuoteWrite a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".


When you've written your newLISP script, read http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/">this blog entry to find out more.