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

Messages - techdir0

#1
newLISP and the O.S. / Re: Puppy Linux
February 18, 2013, 01:22:42 AM
Thanks both - very helpful.



I discovered - quite by accident - that I could use the modules I needed, even without compiling in FFI: just as Lutz points out.



I'll experiment further when time allows, and report back here.
#2
newLISP and the O.S. / Puppy Linux
February 13, 2013, 04:23:22 AM
I wonder if anyone has succeeded in running NewLisp under Puppy Linux, preferably 5.2.8?



If so, is there an SFS available?



UPDATE:



Well, I got the source, and was able to compile it, but had to remove FFI from the compile and link lines in the makefile, to avoid errors.



Seems to be working reasonably well so far ..
#3
newLISP in the real world / Re: Odd problem
August 05, 2011, 08:30:02 AM
Thanks both - I thought I was going mad!



I understand how the debugger handled things - and am/was ready to own up to the original error on my part.



I more often use 'local', so I guess I have left bits of the wrong syntax in the 'let' expression.



Thanks for the help.
#4
newLISP in the real world / Re: Odd problem
August 05, 2011, 03:09:13 AM
I chopped out some more - just hope this does not upset the board (or you guys reading it).

In a file ODD.PL



(define-macro (iparse _sent)
   (setq parses nul)
   (setq stack nul)
   (setq jumpflag nil)
   (setq sentence _sent)
   (setq state 's)
   (setq star (first sentence))
   (atn state sentence)
   (and parses true ) )

(define (pushlex)            
   (push (list star sentence) *lexenvironment) )
 
(define (poplex)            
   (map set '(star sentence) (pop *lexenvironment)) )
   
(define (atn state sentence)
   (let (arcs result (savealist alist))
      (cond ((null? (setq arcs (first (rest (assoc state network)))))
                     nil ))
      (catch
      (while true
         (cond ((setq result (evalarc (first arcs) alist))
                (throw result))
               ((setq arcs (rest arcs)) (setq alist savealist))
               (true  (throw nil)))))))      
                     
 (define (evalarc arc alist)
     (let ((type (arc 0))        
          (head (arc 1))
          (test (arc 2))
          (actions (3 arc)))  
    (cond ((null? (eval test)) nil)
          ((= type 'pop)  (evall actions)
                          (popatn (eval head)))
          ((null? star) nil)
          ((= type 'wrd)  (and (= star head)
                               (evall actions)))
          (else (println "bad arc: " arc) nil) )))                                                                                                                  
               
(define (evall lis)
   (when lis
      (eval (cons 'begin lis)) ))      
   
(define-macro (to _state)
; effect transition to state _state.  
; advance input unless jumpflag is set
; fail if there are no more words in input  
   (cond (jumpflag  (setq jumpflag nil)
                    (pushlex)
                    (setq star (first sentence))
                    (cond ((atn _state sentence)   )  
                          (else (poplex)  nil) ))
         (sentence  (pushlex)
                    (setq star (first (rest sentence)))  ; could we not reverse/simplify these 2 lines?
                    (setq sentence (rest sentence))
                    (cond ((atn _state sentence)   )  
                          (else (poplex)  nil) ))
         (else      (println " blocked : out of words")
                    nil )))                

(define (popatn value)
; pops from a sub-network
    (cond  (stack    ;;; so from earlier push
                 (let ((save star)
                       (savestack stack)
                       (savealist alist)
                       (continuation (rest (first stack))) )
                 (setq alist (append liftlist (first (first stack))))      
                 (setq stack (rest stack))
                 (setq star value)
                 (setq sendlist nul)
                 (setq jumpflag true)
                 (cond ((evall continuation)    )
                       (else (setq star save)
                             (setq stack savestack)
                             (setq alist savealist)
                             nil ) )))
          (sentence (println "pop blocked - unused words")
                    nil)
          (holdlist (println  "pop blocked - non-empty hold list")
                    nil)  
          (else     ;;; final pop                                          
                 (setq parses (cons value parses))
                 true ) ))
   
(define (pushatn state actions)
   ;; STUB
   )
               
(setq network '(                             ;; GRAMMAR 0
   (s ( (wrd grasp true (to s2)) ))
   
   (s2 ( (pop 'success true (println 'OK)) ))
   
))      
       
(set 'dictionary '(                          ;; LEXICON 0
   (grasp  v  () (trans1) )
   (grasp  n  () (reach)  )
 ))  

(define (dict-entry _star _head)                    ; return entry if present, or nil
   (find-all (list _star _head '*) dictionary) )
;; Needs to be like this because we are finding more than one word  with
;; same value, but different category, so will be able to add semantics  

     
(setq nul '())
(constant 'else true)
(setq alist nul
     *lexenvironment nul)
     


I know the style/layout are rubbish - I'm still not very used to (new)Lisp ..



The problem can be seen if you:



(load "odd.pl")
(debug (iparse (grasp)))


the result - after hitting N or S a lot of times - is 'true'; which it should be.



But

(load "odd.pl")
(iparse (grasp))


produces an error.  I am quite ready to believe the error is my fault - but why does it work when I trace the program, trying to fix it???
#5
newLISP in the real world / Re: Odd problem
August 05, 2011, 02:42:42 AM
Well, I would dearly like to, as this has me thoroughly confused.



But I cannot get the program down below 160 lines - which is probably too much to send up to the board?
#6
newLISP in the real world / Odd problem
August 04, 2011, 04:41:40 PM
Hi



I'm not sure how or where to ask this, so here goes.

I'm running 10.3.0 0n Windows XP.  I've converted a program (600 lines) from Common Lisp, and now I have a very odd problem.



The program is a network interpreter, and runs recursively: it works correctly BUT only if I debug through the entire program, hitting 's' several scores of times.    If I try to run the program directly from the REPL, it produces a different result entirely!   There is no error message produced in either case, and I cannot see how to cut down the code to either locate the problem, or post a proper question here.



Anyone got a suggestion?



What's the real difference from running in DEBUG?
#7
That seems to work - thank you for finding it.



I think I will go along with the majority opinion, and stick to the terminal view.   I expect I shall end up using TextPad as my

editor, since I'm used to it, and I can modify the syntax files to suit newLisp.
#8
Well, that would be useful, but it doesn't seem to work that way for me.



This is what happens to me
(begin (setq z (read-line))(println "parse z= " (parse z)))
hey this is great
parse z= ("(" "begin" "(" "setq" "z" "(" "read-line" ")" ")" "(" "println" "parse z= " "("
 "parse" "z" ")" ")" ")")
("(" "begin" "(" "setq" "z" "(" "read-line" ")" ")" "(" "println" "parse z= " "("
 "parse" "z" ")" ")" ")")
> nil
nil
nil
nil


Am I missing something obvious here?
#9
Thanks - I think I understand now what is going on.



Since my interest in newLisp is for natural language interaction, I guess I will work in a terminal until or unless I have a simple graphical interface for the user.
#10
New to Lisp, and newLisp



Why does (setq res (parse (read-line))) produce expected result in command line version,

but return

( "(" "setq" "res" "(" "parse" "(" "read-line" ")" ")" ")" )



if entered in newLisp-gs?? that is, in the IDE.



I'm using v10.1.7 on WinXP