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

#1
newLISP newS / Happy Birthday newLisp
December 06, 2021, 12:00:30 PM
Is newLisp 30 years old? Happy Birthday!
#2
newLISP and the O.S. / OS : El Capitan (10.11)
August 01, 2015, 01:42:13 AM
I understand that the next version of OS X won't allow users to install anything into /usr/bin/. Is this going to affect newLISP installations?



(I may have missed any discussion of this - sorry!)
#3
newLISP in the real world / Problem in crypto.lsp?
March 01, 2014, 10:05:03 AM
Hi Lutz! I ran into a few problems using crypto.lsp. I eventually solved it by editing the hmac function to look like this:


(define (hmac hash_fn msg_str key_str , blocksize opad ipad)
  (set 'blocksize 64)
  (set 'opad (dup "x5c" blocksize))
  (set 'ipad (dup "x36" blocksize))
  (if (> (length key_str) blocksize)
        (set 'key_str (hash_fn key_str true))) ; <----------------
  (set 'key_str (append key_str (dup "00" (- blocksize (length key_str))))) ;; padding key with binary zeros
  (set 'opad (encrypt opad key_str))
  (set 'ipad (encrypt ipad key_str))
  (hash_fn (append opad (hash_fn (append ipad msg_str) true)) true))


I don't know what the problem was, but it currently appears to work on my Mac... :)
#4
If I just click the "View Active Topics" link, I don't seem to see any of the contents of :



http://newlispfanclub.alh.net/forum/viewforum.php?f=12">//http://newlispfanclub.alh.net/forum/viewforum.php?f=12



It looks like the topics in "So, what can you actually DO with newLISP?" aren't registering in the Active Topics list...
#5
newLISP and the O.S. / Port to Android wanted...
December 06, 2012, 09:45:51 AM
Earn some money by porting newLISP to Android...



Elance: probably the original



https://www.elance.com/j/port-newlisp-android/35677444/?backurl=aHR0cHM6Ly93d3cuZWxhbmNlLmNvbS9yL2pvYnMvcS1OZXdsaXNw">//https://www.elance.com/j/port-newlisp-android/35677444/?backurl=aHR0cHM6Ly93d3cuZWxhbmNlLmNvbS9yL2pvYnMvcS1OZXdsaXNw



Donanza, probably derivative



http://www.donanza.com/jobs/p7314944-port_newlisp_to_android_c_android_compiler?utm_source=cebufreeonlinejobsprojects.donanza.com&utm_medium=referral&utm_campaign=wltrk37">//http://www.donanza.com/jobs/p7314944-port_newlisp_to_android_c_android_compiler?utm_source=cebufreeonlinejobsprojects.donanza.com&utm_medium=referral&utm_campaign=wltrk37
#6
I couldn't answer http://stackoverflow.com/questions/11189869/does-newlisp-use-garbage-collection">this question myself, but if you can, and want to earn "valuable" reputation points, please answer it... :)
#7
Can you write beautiful code?



http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html">//http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html



then



https://plus.google.com/117377434815709898403/posts/HQek48JMJb3">//https://plus.google.com/117377434815709898403/posts/HQek48JMJb3
#8
I've been writing an IRC library, but I'm a bit stuck on the best way to arrange things so that you can type input at a terminal while still running an event loop that polls the server periodically. As we know, there's no way you can have a non-blocking read-line, so how would it be possible to combine both 'read' and 'write' tasks into a single terminal window? (My previous attempt - using fork - doesn't seem to be what I'm looking for.)



My 'read' code looks like this:


(define (read-irc)
    (let ((buffer {}))
        (while  (not (net-select Iserver "read" 500))
                (sleep 500))    
        (net-receive Iserver buffer 8192 "n")
        (unless (empty? buffer)
            (parse-buffer buffer))))

(define (read-irc-loop)
    (let ((buffer {}))
        (while Iconnected
            (read-irc))))
#9
I've spent a couple of hours playing with a text editor that was new to me until last week http://www.sublimetext.com/2">Sublime Text.



I know that most people have already chosen their newLISP-editing-machine, whether it's vim or TextWrangler or UltraEdit or Emacs or BBEdit or whatever - I bet some of you have even tattooed the name of your chosen weapon on the back of your neck - but it's often fun to see what other folks are using.



I've had a go at making a basic newLISP package for Sublime Text 2 (you can find it on github at http://github.com/cormullion/newlisp-sublime-text-2-package">//http://github.com/cormullion/newlisp-sublime-text-2-package), and the results are quite interesting - the snippets and autocompletion are quite useful. I've been able to re-use some of taoeffect's work on TextMate, which helps, since the configuration process for defining the language specification is quite complex.



It's very much a work in progress - I might even have stopped work on it already, who knows :) - so feel free to adopt, adapt, and improve.
#10
Running this object-oriented FOOP code:


(new Class 'C)
(context C)
(define (C:C) (list (self 0)))
(define (C:hw) (println "hello world"))

(define (C:do_it)
 (let ((i 0))
   (while (< (++ i) 1000000)
       (hw))))

(context MAIN)
(new C 'my-c)
(my-c:do_it)
(exit)


It's trying to be an exact copy of this Python:


class c:
def hw(self):
print 'Hello World!'

def do_it(self):
i = 0
while i < 1000000:
i = i + 1
self.hw()

inst = c()
inst.do_it()


But the newLISP seems very sluggish. Is it some FOOP-related issue that prevents this from being efficient code? (There are obviously many easier ways to accomplish the same thing without FOOP.)
#11
newLISP in the real world / Another challenge
March 07, 2011, 11:05:40 AM
I thought this thread on comp.lang.lisp was quite entertaining https://groups.google.com/d/topic/comp.lang.lisp/sJdB5SXzcU0/discussion">//https://groups.google.com/d/topic/comp.lang.lisp/sJdB5SXzcU0/discussion. It's to produce the list:


((1 "a") (1 "b") (1 "c") (1 "d") (2 "a") (2 "b") (2 "c") (2 "d") (3 "a")
 (3 "b") (3 "c") (3 "d") (4 "a") (4 "b") (4 "c") (4 "d") (5 "a") (5
"b") (5 "c") (5 "d"))




Can you provide a newLISP alternative to the various loops, mapcans, collects, iters, and nconcs? Can you avoid creating intermediate storage? Can you do all this while resisting the urge to insult other programmers?! :)



Obviously, there's a simple iterator solution, using two dolists. I found a shortcut in newLISP. Can you find it?
#12
newLISP in the real world / This week's challenge
February 27, 2011, 09:21:47 AM
Write a function that transforms a list of strings:


(set 'l '(
"aa"
"a12"
"aaaa123"
"aaa12"
"aa1112"
"b"
"ba"
"b12"
"bbaa123"
"baa12"
"ba1112"
"c1"
"c2"
"c1313"
"c1121aa"
"caababb"
; and so on
))

into a list of lists of strings:
'(("a12" "aa" "aa1112" "aaa12" "aaaa123")
  ("b" "b12" "ba" "ba1112" "baa12" "bbaa123")
  ("c1" "c1121aa" "c1313" "c2" "caababb"))
#13
newLISP and the O.S. / iPad users wanted...
December 11, 2010, 10:31:05 AM
Just wondered if any iPad users out there could have a look at this page:



http://unbalanced-parentheses.nfshost.com/lambdalator/">//http://unbalanced-parentheses.nfshost.com/lambdalator/



and tell me whether the display works automatically for iPad or needs adjusting.



I don't think Santa will bring me an iPad this year ... :)
#14
newLISP Graphics & Sound / SuperCollider - for newdep :)
November 19, 2010, 11:58:23 AM
Can't guarantee antimatter....


#!/usr/bin/env newlisp

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)
(gs:frame 'SuperCollider 100 100 550 550 "SuperCollider")
(gs:set-border-layout 'SuperCollider )
(gs:canvas 'MyCanvas  'SuperCollider)
(gs:add-to 'SuperCollider 'MyCanvas "center")
(gs:set-background 'MyCanvas gs:black)
(gs:set-anti-aliasing true)

(set 'width 550 'height 550
 'x (* 5 (- (rand 3) 1))  'y (* 5 (- (rand 3) 1))
 'delta-x (* 5 (- (rand 3) 1))
 'delta-y (* 5 (- (rand 3) 1))
 'circle-radius 4)

(gs:set-translation (/ width 2 ) (/ height 2))
(gs:set-size 'MyCanvas width height)

(set 'apoly1 '(
(-0 -85) (-23 -103)
(-55 -112) (-114 -90)
(-114 -90) (-75 -103)
(-38 -89) (-18 -57)
(-18 -33) (-25 -14)
(-52 9) (-73 14)
(-95 11) (-125 -10)
(-135 -50) (-134 -15)
(-121 11) (-72 41)
(-77 76) (-67 106)
(-21 142) (-50 118)
(-58 99) (-58 75)
(-38 42) (-0 27)
(38 42) (58 75)
(57 99) (50 118)
(21 142) (47 128)
(66 106) (76 76)
(72 40) (120 10)
(133 -16) (133 -52)
(123 -11) (94 11)
(71 14) (50 9)
(23 -14) (16 -33)
(17 -57) (37 -89)
(75 -103) (97 -99)
(113 -89) (112 -90)
(89 -105) (54 -112)
(22 -103) (0 -85)
))
(define (init)
 (gs:fill-rect 'Frame (/ (- width) 2) ( / (- height) 2) width height '(0.1 0.2 0.1))
 (gs:fill-polygon 'Container1 (flat apoly1) gs:black)
 (gs:fill-circle 'Electron x y circle-radius gs:green))

(set 'PI 3.14159 'TWOPI (add PI PI))

(define (angle2d x1 y1 x2 y2)
 ; Return the angle between two vectors
 ;   The angle is from vector 1 to vector 2, positive anticlockwise
 ;   The result is between -pi -> pi
 (set 'theta1 (atan2 y1 x1))
 (set 'theta2 (atan2 y2 x2))
 (set 'dtheta (sub theta2 theta1))
 (while (> dtheta PI)
  (dec dtheta TWOPI))
 (while (< dtheta (- PI))
  (inc dtheta TWOPI))
 dtheta)

(define (inside? pt poly)
 ; point is a list (x y)
 ; poly is a list of points ((x y) (x y))
 ; uses "the worst algorithm in the world for testing points"
 ; http://erich.realtimerendering.com/ptinpoly/
 (let ((inside nil)
       (len (length poly))
       (point-x (pt 0))
       (point-y (pt 1))
       (max-x 0) (min-x 0)
       (max-y 0) (min-y 0)
       (angle 0))
  (set 'max-x (first (apply (fn (a b) (if (>= (first a) (first b)) a b)) poly 2)))
  (set 'min-x (first (apply (fn (a b) (if (<= (first a) (first b)) a b)) poly 2)))
  (set 'max-y (last (apply (fn (a b) (if (>= (last a) (last b)) a b)) poly 2)))
  (set 'min-y (last (apply (fn (a b) (if (<= (last a) (last b)) a b)) poly 2)))
  (cond
   ; quick bounds check
   ((or  (< point-x min-x)
     (< point-y min-y)
     (> point-x max-x)
     (> point-y max-y)) inside)
   (true
    ; OK. Do it the hard way.
    (for (i 0 (- len 1))
     (set 'p1x (sub (first (nth i poly)) point-x))
     (set 'p1y (sub (last  (nth i poly))  point-y))
     (set 'p2x (sub (first (nth (% (+ i 1) len) poly))  point-x))
     (set 'p2y (sub (last  (nth (% (+ i 1) len) poly))  point-y))
     (set 'angle (add angle (angle2d p1x p1y p2x p2y))))
    (if (< (abs angle) PI)
     (set 'inside nil)
     (set 'inside true))))
  inside))

(define (init)
 (gs:fill-rect 'Frame (/ (- width) 2) ( / (- height) 2) width height '(0.2 0.2 0.3))
 (gs:fill-polygon 'Container1 (flat apoly1) gs:black)
 (gs:fill-circle 'Electron x y circle-radius gs:green))

(define (move-shape)
 ; hit walls, bounce back
 (if (<= x (+ circle-radius (- (/ width 2))))  (set 'delta-x (- delta-x)))
 (if (<= y (+ circle-radius (- (/ height 2)))) (set 'delta-y (- delta-y)))
 (if (>= x (- (/ width 2) circle-radius))      (set 'delta-x (- delta-x)))
 (if (>= y (- (/ height 2) circle-radius))     (set 'delta-y (- delta-y)))
 (inc x delta-x) (inc y delta-y)
 (gs:move-tag 'Electron delta-x delta-y)
 (if  (inside? (list x y) apoly1)
  (begin
   ; change color of electron
   (gs:color-tag 'Electron gs:white)
   ; mark if we find something
   (if (= 0 (rand 6)) (gs:fill-circle 'Target x y circle-radius gs:yellow))
   ; randomize movement
   (set 'delta-x  (* 5 (- (rand 3) 1)))
   (set 'delta-y  (* 5 (- (rand 3) 1))))
  (gs:color-tag 'Electron gs:red))
 (gs:update))

(gs:set-visible 'SuperCollider true)
(init)
(while (gs:check-event 1000)
 (move-shape))
;eof
#15
newLISP in the real world / term and prefix documentation
November 13, 2010, 03:22:00 AM
Hi Lutz! Could you expand the documentation for term and prefix? From the descriptions, I can't really explain to myself what the problem is here:


> (set 's "Fred")
"Fred"
> (term s)

ERR: symbol or context expected in function term : "Fred"
> (prefix s)

ERR: symbol expected in function prefix : s
>


s is a symbol? Perhaps it's not supposed to work if it's not in a context, but I think it should be clear from the docs if that's the case.
#16
I've forgotten whether it's possible for a function to find out in which context it's being called from.




(context MAIN)
(define (f)
   (println "hi there I'm in context " (context)))
   
(global 'f)
(f)
hi there I'm in context MAIN

(context 'Fred)
(f)
hi there I'm in context MAIN


Each returns MAIN, but is it possible to write the f  function so that it returns 'Fred when it's in Fred?
#17
Playing with this area of newLISP. It seems to be not possible to communicate errors using catch.


> (catch (eval-string {(+ 2 2)}) 'result)
true
>
> result
4
> (catch (eval-string {(+ 2 2}) 'result)
nil
> result
"ERR: missing parenthesis in function eval-string : "...(+ 2 2                              ""
>
> ; so the basic idea works. Try it with spawn...
>
> (spawn 'p1 (catch (eval-string {(+ 2 2)}) 'result))
15789
> (sync 10)
true
> p1
true
> result
"ERR: missing parenthesis in function eval-string : "...(+ 2 2                              ""
>


Is there a way to get results and errors from a spawned process using catch? Or is it a job for send/receive?



(newLISP v.10.2.8 on OSX IPv4 UTF-8)
#18
Heard on the VFX podcast #110:



Mike Seymour: "for those of you who don't know, [Kanen] has a very strong background in security, programming, and what I like to refer to as "Big H" hacking. You've been into programming stuff for years?



Kanen: That's true and in fact, ironically,  I'm in lovely Boca Raton hanging out with the creator of the programming language called newLISP. It's the most popular Lisp out there, and i just spoke at a conference yesterday, my birthday, called Hacker Halted...



I love that 'most popular Lisp out there', Kanen! No argument from me, at least... :)
#19
newLISP and the O.S. / Syntax for the Gedit editor?
October 15, 2010, 08:37:34 AM
So I started looking at the Gedit text editor. At first sight it's quite pleasing. Has anyone got a newLISP syntax file for gedit? If not, I will have the pleasure of trying to get one started...



I tried to give vim and macvim a fair trial. But having to switch modes constantly didn't feel right to me...
#20
I've been struggling with some code, and I think it's crashing with a segmentation fault when a replace call attempts to do a complex regex replacement on a large amount of text. After much investigation, I have a suspicion that  the limit is a string around 225,000 characters long. This turns about to be more than two-thirds but less than threequarters of the length of a document such as the Introduction to newLISP. (Ie the code crashes when applied to the whole document but not on a substantial proportion of it. A hard bug to find... :))



First I thought I'd ask to see if there might be some hard limit in replace? The regex is a nested thing, so I'm assuming there's some hard limit to how much you can do once the regexen get a bit complicated...