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

#1
newLISP in the real world / variable capture?
November 13, 2011, 12:55:05 PM
I don't understand what I'm doing wrong here. Is it variable capture?



Using the example from the define-macro description in the newLISP doc I wrote two identical test functions, apart from the name of the parameter:


(define-macro (dolist-while)
  (letex (var (args 0 0)
          lst (args 0 1)
          cnd (args 0 2)
          body (cons 'begin (1 (args))))
    (let (res)
      (catch (dolist (var lst)
               (if (set 'res cnd) body (throw res)))))))

(define (test1 a-list)
  (dolist-while (x a-list (!= x 'd)) (println x)))

(define (test2 lst)
  (dolist-while (x lst (!= x 'd)) (println x)))

(test1 '(a b c d e f))
(test2 '(a b c d e f))


here is the output


newLISP v.10.3.3 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.

>
(lambda-macro ()
 (letex (var (args 0 0) lst (args 0 1) cnd (args 0 2) body (cons 'begin (1 (args))))
  (let (res)
   (catch
    (dolist (var lst)
     (if (set 'res cnd)
      body
      (throw res)))))))
(lambda (a-list) (dolist-while (x a-list (!= x 'd)) (println x)))
(lambda (lst) (dolist-while (x lst (!= x 'd)) (println x)))
a
b
c
nil

ERR: list expected in function dolist : lst
called from user defined function dolist-while
called from user defined function test2
>
#2
I'm trying to set a character value in a string containing zeros. Is the following behaviour correct?



newLISP v.10.3.3 on OSX IPv4/6 UTF-8, execute 'newlisp -h' for more info.



> > (set 's "abc")

"abc"

> (setf (s 1) "X")

"X"

> s

"aXc"

> (set 's "000000")

"000000"

> s

"000000"

> (length s)

3

> (setf (s 1) "X")



ERR]
#3
newLISP Graphics & Sound / glDrawPixels possible?
October 24, 2011, 02:36:26 PM
Is it possible to use glDrawPixels from a newLISP script? I want to display an image I've constructed in an array of RGB values.



If it is possible, could you point me to the documentation or an example?



If it isn't possible, am I trying to do something newLISP is not designed for?