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

#41
Hello everyone,



Consider this function which adjoins one element 'x' to a set 'S', non-destructively.
(define (adjoin1 S x)
  (if (or (= x nil) (= S nil) (member x S))
      S
      (cons x S)))
> (define L '(1 2 3))
(1 2 3)
> (adjoin1 L 0)
(0 1 2 3)


Now to adjoin more than one element (at a time), it seems natural to then say
(define (adjoin S)
  (if (empty? (args))
      S
      (apply adjoin
             (cons (adjoin1 S (first (args)))
                   (rest (args))))))

but this does not work --- it fails on a 'call stack overflow'.



Now, yes, I know that the alternative definition
(define (adjoin S)
  (if (empty? (args))
      S
      (let ((result S))
        (dolist (x (args))
          (set! result (adjoin1 result x))))))

works and indeed, there are other ways also, for instance:
(define (adjoin S) (unique (append S (args))))

However, why doesn't the first (recursive) definition of 'adjoin' work?  (I like the last definition, but I may need to define a recursive function in the future and so still need to figure out what is going on with the first definition.)



Thanks!  --Ricky
#42
newLISP newS / Makefile change: uninstall target
April 14, 2005, 08:07:43 PM
Hello Lutz,



This would be a small change to 'Makefile' in the distro, but I recommend to change the 'uninstall' section according to this 'diff' output:


204,208c204,208
<       -rm  /usr/bin/newlisp
<       -rm  /usr/bin/newlisp-tk
<       -rm  -rf /usr/share/newlisp
<       -rm  /usr/share/man/man1/newlisp.1
<       -rm  /usr/share/man/man1/newlisp-tk.1
---
>       -rm  $(bindir)/newlisp
>       -rm  $(bindir)/newlisp-tk
>       -rm  -rf $(datadir)/newlisp
>       -rm  $(mandir)/man1/newlisp.1
>       -rm  $(mandir)/man1/newlisp-tk.1


Cheers,  --Ricky
#43
Hello everyone,



I have a question regarding the use of expressions returned from newlisp.dll to an Excel spreadsheet (thanks BTW for providing the Excel VBA "glue code" to newlisp.dll).  Everything seems to work great, until I need to assign newlisp list components to cells of a spreadsheet.  Is that possible?  If so, then how?



For instance, say I have defined a function in newlisp called 'my-list-maker'.  Then if I put in cell A1 '(my-list-maker <args>)' and the function call '=newlispeval(A1)' in another cell, I get the printed representation of the list in this cell (which can be rather long, as in my particular application).  It would be nice to be able to say instead '=newlisp_destruct_value_vertically(A1)' and the list components could be put one-by-one in a vertical column starting with the cell containing the function call.  This would be useful, say when one wants to use Excel to graph a list of numbers coming from newlisp.



I wonder if this is possible and I admit much ignorance regarding Excel -- perhaps this is why the solution eludes me.  Thanks for any help!  --Rick