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 - Excalibor

#1
Whither newLISP? / Modern LISP and newLISP on reddit
October 06, 2009, 01:03:46 AM
Hi,



A reddit user asked what's a good, modern LISP to learn and among the usual cruft about Common Lisp (which is cool) came Scheme (flavours), Clojure, Rebol (surprising, but it's actually quite cool, shame on licensing) and newLISP.



As usual, our newlispers have been downvoted, so after 'rescuing' them, i think some good things can be said over there so it takes some notice?



http://www.reddit.com/r/programming/comments/9qzm5/whats_a_good_modern_lisp_to_learn/">http://www.reddit.com/r/programming/com ... _to_learn/">http://www.reddit.com/r/programming/comments/9qzm5/whats_a_good_modern_lisp_to_learn/



laters!
#2
Whither newLISP? / Parallelism and newLISP
June 05, 2009, 02:12:17 PM
Greetings!



I'm sure many of you have read Guy Steele's recent article about multicore, parallel programming...



If you have not, here's the link to the PDF file: http://groups.csail.mit.edu/mac/users/gjs/6.945/readings/MITApril2009Steele.pdf">http://groups.csail.mit.edu/mac/users/g ... Steele.pdf">http://groups.csail.mit.edu/mac/users/gjs/6.945/readings/MITApril2009Steele.pdf



The thing is, he splicitely mentions linked lists as being conceptually sequential and thus hardly parallelizable (this is, traditional LISP lists) and exposes some interesting tree proposals as parallelization strategies (not that I have been able to understand everything at a first glance, and I haven't been able to really read the article stopping where things get hairy).



Anyway... I was wondering how's newLISP ready for the multicore future (coincidentally this netbook of mine presents itself as a dual-core CPU, I think it's because Linux is treating hyperthreading as multicore... anyway, maybe Intel's Atom is dual core, I dunno, and I don't really care right now :-P ---)



This is just for the sake of discussion and planning... I did some useful scripts in newLISP at work and it may become my second tool for some more, after Perl, and some of those will do some really heavy string comparison magic, so I was wondering how to parallelize them to be able to take HP Blade's dual-core with hyperthreading presenting themselves as 4-core machines... :-)



I am thinking that I may divide the search space so I can launch 4 parallel processes at once, and thus saving, surely, lots of time designing the algorithms, but I thought that asking you guys may be very wise nevertheless... :-)



Anyway, thanks for your thoughts!
#3
newLISP Graphics & Sound / Problem with newLISP-GS
March 26, 2009, 08:14:15 AM
Greetings,



I dunno if this is common to all platforms, but I have particularly noticed in my windows machine at work:



I run newLISP-GS, hack around, leave it open and when I come back the next day (the machine has tasks to do during the night, so it's on during the week) my newLISP-GS session is gone.



As I usually prefer using gVIM and a shell for development, I only use newLIPS-GS for the convinience when testing functions or ideas, so I don't really know if I have lost any data. I did lost, however, my hacking session, which is not bad but it's annoying, unless it's saved somewhere else I don't know about...)



Can anyone confirm this behavior? If so, can be fixed? A /tmp/ buffer file like in VI could be nice for this kind of happenings... it would provide a recovery option, or at least something similar...



Anyway, I just thought I'd let you know, for future releases...



Also, if I can get some free time, I'll try to check the sources myself, but even then I won't promise any result :-)



thanks!



PS- posted inadvertently on the Unixen forum, moved here as fast as I could.
#4
Whither newLISP? / (but-last) ?
March 24, 2009, 07:54:31 AM
Hi there,



This is a problem that has arisen several times now in my programs (which do some heavy text file parsing)



I get a text line, (parse) it and then I need a list of tokens but the last one.



A silly example: getting the base URI from a given URI:



 "http://example.com/path/to/files/file1.html">http://example.com/path/to/files/file1.html"



There's surely a hundred ways to do this, but I simply (parse) it given all possible token separators and I get the list



("http" "example.com" "path" "to" "files" "file1.html")



I needed a simple (but-last) function to get all elements but the last one to use is some loops:



I came with different solutions, these are my favourites:


(define (but-last lst)
  (rest (rotate lst)))

(define (but-last2 lst)
  (1 (- (length lst) 1) lst))

(define (but-last3 lst)
  (chop lst))


You see, the first one is "less optimal" than the second, but it only mentions lst once and, alas, is more useful to on-the-fly generated lists . OTOH performance is not that horrible, so it's a nice hack (instead of slicing, twisting, kind of) :-)



Then, reading more into the documentation, I arrived to chop. Doh!



So...



We have an asymmetry in here:


'(this is a list)

 first    rest

 chop     last


So, maybe an alias chop = but-last, except-last, almost-all, firsts could be useful?



I mean, we have the "first" and the "rest" of a list, we could have the "firsts" and the "last"? The truth is (chop) is not an intuitive name for this task, even when it's covered by it.



In my view, the fact that newLISP treats strings and lists the same for many different kind of things is not a favor in this case. I'm thinking in the new user, because I'm a kind-of new user, and, well, you know... :-P



Anyway, your thoughts?



laters
#5
newLISP and the O.S. / (parse-date)
March 18, 2009, 06:17:33 AM
Greetings,



I'm writing a script for parsing the output of the 'last' command, and I have found that (parse-date) gives an error. This is in 10.0.2 in Windows (both in newLISP GS and using it with cygwin)



> (sys-info)

(391 268435456 367 1 0 2048 3268 10002 6)

> (parse-date)



ERR: invalid function : (parse-date)



Is there something I'm overseeing or is it a bug in the Windows release? v10.0.2 on GNU/Linux works fine, though...



Thanks a bunch!
#6
newLISP in the real world / Return value of make-dir
March 05, 2009, 03:32:43 AM
Greetings,



Recently I found out that a script of mine stopped working under cygwin when it had been working OK for weeks.



Debugging it, I found out that, for some reason, the permissions on the base directory were incorrect and the user the script was running under couldn't create a new directory. Now, the script makes a new directory every day (based on the current date) and that's obviously bad.



Unless I'm wrong (which is, after all, very probable) make-dir just returns true or false accordingly to it being able to create or not the new directory.



Is there a system variable where I can check the reason why it hasn't been able to create the new directory? If not, would it be possible to provide it in further releases? Because it was as simple as issuing a chmod command (with the same user, it was the owner, but mod had been changed to 0444 for some reason) and that can be coded into the script.



thanks!
#7
Greetings!



LTNS, actually... I'm unrusting myself with an interesting page I found, essays in J language ( http://www.jsoftware.com/jwiki/Essays">http://www.jsoftware.com/jwiki/Essays ).



I am trying the first one, the Collatz conjecture, http://www.jsoftware.com/jwiki/Essays/Collatz_Conjecture">http://www.jsoftware.com/jwiki/Essays/C ... Conjecture">http://www.jsoftware.com/jwiki/Essays/Collatz_Conjecture , and I was wondering how do you do in idiomatic newlisp the kind of collect that's displayed there, which is a kind of fold operation:



"apply function recursively and accumulate the results until it returns nil..."

"



I haven't really thought a lot about it yet, and my first attempt, which I offer below, is pretty naive, although it works...



anyone up to discuss about this?



thanks!



PS- the code:



(context 'collatz)

(define (collatz1 n)
  (if (<= n 1)
nil
(if (= (mod n 2) 0)
 (/ n 2)
 (+ 1 (* 3 n)) ) ) )

(define (collatz:collatz n)
  (let ((ret '()))
(do-while (> n 1)
(setq n (collatz1 n))
(push n ret -1) )
ret ) )

(context 'MAIN)

> (collatz:collatz 9)
(28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1)
[/code]
#8
newLISP in the real world / Unicode and newLISP-tk
April 28, 2005, 01:42:41 AM
Hi all,



I dunno exactly how Unicode support is done (or not) in newLISP, I have to dig into the docs and code, but this is a session of newLISP 8.5.4 with newLISP-tk 1.2.5



> (setq Πελειάδεω 10)
10
> (println Πελειάδεω)
10
10
>


Pretty impressive, actually... (BTW the symbol reads, in classical greek, "Peleiádeo-o", which is the genitive form of Peleos, the father of Achilles, from the first verse of the _Illiad_, which I copy&pasted from my blog, which starts with that first verse...)



I dunno which encoding was used, because copying from firefox to newlisp-tk, and then back to firefox may have caused haymen with the encodings, but anyway...



:-)



laters!

dvd



PS- this also works: (setq ñañañá 13)   :-)
#9
Anything else we might add? / define-macro and debugging
December 16, 2004, 02:29:14 AM
Hello!



Last development version of newLisp is really pretty (I should try and work on the vim mode, I will during the holidays) and have some nifty features, sp. regarding lexical scope with contexts...



So I want to write a protected macro, let's say a silly one that doesn't work:



(define-macro (do-but:do-but condition body)
  (if (= (eval condition) true)
   true
   (begin
    (eval body)
    (do-but condition body))))


I am basically trying to make a new construct that works like do-until, i.e. "do body but stop at condition".



Tested with:

(set 'x 1)
(do-but (= x 10) (begin (+ x 1) (print x)))

I get:

[code>

1

call stack overflow : if

[/code]



Now, I launch the debugger and the editor but I find this:



(define-macro (do-but:do-but MAIN:condition MAIN:body)
  (if (= (eval MAIN:condition) true)
   true
   (begin
    (eval MAIN:body)
    (do-but MAIN:condition MAIN:body))))

This is what newLisp sees, and once inside the debugger I cannot see the condition... both MAIN:condition and do.but:condition are nil...



Now, I suspect I should throw a labdba or two on that to make it work, but my question(s) is(/are): is the editor showing a bug? did I read badly that the macro arguments would be in its context when defining it this way? How do I see the value of something inside the debugger (specially when I'm debugging a macro)?



Lastly, though I want to fight this myself, a helping hand will be appreciated :-)



thanks,
david



PS: there's a Common Lisp tutorial on the web that's making a simple interactive rpg game. I wanted to translate it to newlisp as a means of practising and if the original author allows as a tutorial on newlisp for others... He proposes calling macros SPEL: Semantic Program Enhancing Logic... his reasons are probably sound, and nevertheless he makes a kind of macro alias, I am trying to get his defspel done in newlisp if its possible, and I don't see why not... URL: http://www.lisperati.com/spels.html">http://www.lisperati.com/spels.html Thx!
#10
Hi!



I've been reading and thinking a bit...



how hard would it be for define-macro to automagically switch to a new context each time it's called? This would avoid variable collision in a very elegant way, even if multiple expansions are being performed...



I gotta go now, but I'l post an example when I'm back home in an hour or so but the idea is:



(define-macro (foo x) (begin (set 'M (symbol (random)))(context 'M)(*macro goes in here *)(context 'MAIN)))

(set 'x 1)

(print (foo 45)) ; in here 45 is referred by 'M:x and M is different everytime (or it should be) so it's not posible that the expansions collide...

(print x) ; => prints 1



well i don't seem to make a good enough example in such a rush, will make later



regards,

david
#11
Anything else we might add? / new string quotes macro
September 21, 2004, 07:13:20 AM
Hi all,



this is probably either stupidly easy or really hard/impossible to do, but in any case I am mid-way and a bit lost, so I will appreciate the help.



The case is that I dislike the [text][/text] things we have to use for >2kb strings (I guess this limitation for "" {} is a design tradeoff) because it's so unlispy...



so I decided to put the macros into work:



(define-macro (text)

  (eval (join (list '[text] (args) '[/text]) " ")))



now you start to see my problem... the string is parsed before the (quote) can quote it...



Second try:



(define-macro (text)

  (eval (join (list "[text]" (string (args)) "[/text]") " "))))



and this produces the funny result:



(text hello there dude!)

"[text] (hello there dude!) [/text]"



even playing around with (join (list (string (args) " "))) and so on works as badly as the previous solutions...



I wonder if using simply (string) would work... (tested it, and it doesn't exactly work... and I'm not sure it would work for >2kb args list...)



any ideas?

thank!

david
#12
newLISP newS / ViM syntax file?
July 13, 2004, 03:18:47 AM
Hello there!



has anyone, by any luck, written a syntax file specifically for newLISP syntax? Neither LISP nor Scheme suit it perfectly...



I could do so myself, and probably will do if nobody has just done before me :-P



thanks for all,

david



PS- testing 8.0.8; it's working 100% so far