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

#1
On page 40 in bullet list underneath Building Lists, "cons prepends an element to a list or make a list" should be "...makes a list".



--hsm
#2
newLISP newS / Typo in the User Manual pdf version
July 12, 2009, 01:27:41 AM
Page 270, last line of the displayed code, RREPLACE_ONCE should be REPLACE_ONCE.



--hsm
#3
Normally when I'm coding I depend on the bouncing cursor to tell me which expression I'm closing up, but I noticed that the cursor will match lines that have been commented out. I suspect that this is not intended?



--hsm
#4
Whither newLISP? / Values and void
July 10, 2009, 09:03:05 PM
In CL and scheme empty version of values and void are used to indicate nothing is returned.


(define (f)
  (print 5)
  (newline)
  (void))

or


(defun f ()
  (format #t "~d~%" 5)
  (values))


Is there a newLISP equivalent? If not could there be?



--hsm
#5
newLISP Graphics & Sound / Cut, Paste etc. in IDE
July 10, 2009, 03:18:30 PM
Under Windows XP with the latest code, ^Z, ^V, ^X don't seem to set the 'this file has changed flag'.



--hsm
#6
newLISP newS / Simple macros
July 09, 2009, 06:37:58 AM
Are there advantages/dis-advantages to implementing simple one-liners as macros? For instance
(define (even? n)
   (zero? (% n 2)))

versus the macro definition.



--hsm[/code]
#7
newLISP newS / Docs and PDF
July 08, 2009, 09:08:55 PM
I know you are working (or were) on PDF files for the new documentation. Could you include the doc on the GUI as well?



--hsm
#8
newLISP newS / Tweaks to the install package...
August 08, 2008, 07:56:45 AM
Each time I install a new version, the software offers to add newLISP to the path. Would it actually duplicate the original addition if I leave this checked? On a similar note, could creating a shortcut be and option and not forced?



--hsm
#9
What &whatever; are allowed in a post (of course with HTML on)?



—hsm
#10
newLISP Graphics & Sound / 2 problems noted
April 28, 2008, 10:41:55 AM
I don't know how easy this will be to duplicate, but I've had to deal with two problems in the editor.



1. use ALT-2 to place cursor in REPL window, then

2. a simple click back in editor window flips the changed status.

3. next, after a save and a switch to the REPL window, hitting return results in:

newLISP v.9.3.11 on Win32 IPv4, execute 'newlisp -h' for more info.

>
> --- 9841 bytes saved to C:/Documents and Settings/hsmyers/My Documents/newLISP-Dev/newBoard/ps.lsp ---

nil
nil
nil
nil
nil
nil
nil
newlisp
nil
for
nil
nil
> > > <40CF0C>
> > <40CF0C>
nil
9841
nil
nil
nil
nil
and <4097A1>
nil
nil
nil
> >

I don't think that is correct? Perhaps the save message is being evaluated?



--hsm
#11
newLISP newS / typo in manual
April 24, 2008, 12:38:51 PM
In the entry for pop-assoc the syntax line reads "syntax:(pop(" and should read "syntax:(pop-assoc("



--hsm
#12
newLISP newS / assoc add?
April 24, 2008, 12:36:33 PM
I noticed the absence of push-assoc while wandering through the manual and of course that raised the obvious question. Probably under the heading of "stupid questions", but how do you add to an associative list? I tried what seemed to be the simple approach:
> (setq g1 '(("tags" ("Event" "Northern Idaho Open"))("moves" "d4" "f5")("fen")))
(("tags" ("Event" "Northern Idaho Open")) ("moves" "d4" "f5") ("fen"))
> (list? (last g1))
true
> (push "test" (last g1))
"test"
> (last g1)
("fen")

With entirely non obvious results at least to me!



--hsm
#13
Anything else we might add? / Destructive functions?
April 14, 2008, 02:08:25 PM
What is the pattern for writing functions that change their parameters in the calling scope? For instance this clearly doesn't work:

(define (strip move)
  (replace "[+#]" move "" 0))

So what would?



--hsm
#14
newLISP newS / Pi
April 11, 2008, 05:08:50 PM
Found this while wandering around the internet:

; Copyright (c) 2008 the authors listed at the following URL, and/or
; the authors of referenced articles or incorporated external code:
; http://en.literateprograms.org/Pi_with_Machin's_formula_(Lisp)?action=history&offset=20060307031705
;
; Permission is hereby granted, free of charge, to any person obtaining
; a copy of this software and associated documentation files (the
; "Software"), to deal in the Software without restriction, including
; without limitation the rights to use, copy, modify, merge, publish,
; distribute, sublicense, and/or sell copies of the Software, and to
; permit persons to whom the Software is furnished to do so, subject to
; the following conditions:
;
; The above copyright notice and this permission notice shall be
; included in all copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;
; Retrieved from: http://en.literateprograms.org/Pi_with_Machin's_formula_(Lisp)?oldid=2756

(define (arccot x unity)
  (let ((xpower (floor (/ unity x))))
    (arccot-plus-helper (* x x) 1 xpower)))

(define (arccot-plus-helper xsq n xpower)
  (let ((term (floor (/ xpower n))))
    (if (= term 0)
        0
      (+ (arccot-minus-helper xsq (+ n 2) (floor (/ xpower xsq)))
         term))))

(define (arccot-minus-helper xsq n xpower)
  (let ((term (floor (/ xpower n))))
    (if (= term 0)
        0
      (- (arccot-plus-helper xsq (+ n 2) (floor (/ xpower xsq)))
         term))))

(define (pidigits digits)
    (letn (
      (unity (pow 10 (+ digits 10)))
      (pi (* 4 (- (* 4 (arccot 5 unity)) (arccot 239 unity)))))
      (floor (/ pi (pow 10 10)))))



I converted it to newLISP by the obvious means (defun to (define. Didn't have a (expt function so I substituted (pow. On my 32bit machine (pidigits works up to 8 digits(yeah I know--- impressive!) then I get the following:

> (pidigits 6)
3141592
> (pidigits 7)
31415926
> (pidigits 8)
314159265
> (pidigits 9)
-791741031


I'm curious if this is some sort of limit reached with 32bit math? Could someone with a 64bit system give this a run?



--hsm
#15
newLISP newS / Parsing problem
April 09, 2008, 08:55:58 AM
> s
"[Event this is the first event [Event this is the second event [Event and this is the third"

> (regex "[\[]" s 0)
("[" 0 1)
> (parse "[\]]" s 0)

regular expression in function parse : "offset 91 missing terminating ] for character class"

If regex is happy, what is parse's problem? Please enlighten me.



--hsm



UPDATE: uh--- Duh! How about wrong order of parameters in parse? Ignore this post please...
#16
newLISP newS / newLISP-GS problems and prayers
April 05, 2008, 01:46:54 PM
Files->Recent Files seems broken. Regardless of which file or files I edit, the only thing that shows up in the list is newlisp-edit.config.



On to prayers. I'd like to suggest
(gs:set-font 'OutputArea currentFontName currentMonitorFontSize "plain")
Or the even better
(gs:set-font 'OutputArea currentMonitorFontName currentMonitorFontSize "plain")
And as long as we are tinkering, could OutputArea become the active window after a run? Perhaps I don't understand, but I can't figure out why anyone would want to stay in the edit area after a run.



One last request; could the nag popup about leaving the app be restricted to the one that asks about changed files. If I haven't done anything(or have saved my work) why should I have to click twice to leave?



--hsm
#17
newLISP newS / Current newLISP edit directory?
March 26, 2008, 02:30:40 AM
When loading a file into newLISP edit what is the current directory? I ask because I got this error message
problem accessing file in function load : "rank-list.db"

based on this code
 (load "C:\Documents and Settings\hsmyers\My Documents\newLISP-Dev\newBoard\file-list.db")
  (load "rank-list.db")

Obviously the first time through I got the error message on the first load until I fully qualified it. I'm pretty sure I shouldn't have to. I am not sure about what I need to do to fix this. The likely suspect would seem to be a current directory mismatch between the newLISP edit and the development directory--- yes?



--hsm
#18
newLISP newS / Character math?
March 23, 2008, 01:38:34 PM
What is the fastest way to increment/decrement a character? At the moment I'm looking at(define (incr-char c)
(char (+ (char c) 1)))

(define (decr-char c)
(char (- (char c) 1)))


While it works, I've got my doubts--- I'm fairly sure it could be made better. I noticed the code for ++ and I am thinking about the ability to change the original as well as just return char + 1 etc. In assembler this is either a 'inc' or 'dec' on the dereferenced pointer and it bothers me that I don't have something similar. What say you all?



--hsm
#19
newLISP newS / Identity function
March 20, 2008, 01:02:26 PM
(define (return x) x)

Gives me a self-documenting way of avoiding both catch, throw and eval as well. Please criticize?
#20
newLISP newS / Idiomatic code
March 18, 2008, 11:51:14 AM
In every language there is an idiomatic way of expressing the more common patterns. One of the things I am looking for is a more elegant (not to mention more efficient) way of returning values from a function or portion of a function (very nearly the same thing...) Consider:


(define (parse-move n g)
  (let (s (get-move n g))
    (if (= 2 (length s))
(filter on-board?
        (begin
          (if (black-to-move? n)
            (let (lst (list (next-diagl s)(next-diagr s)(next-row s)))
              (if (= "6" (row s))
                (append lst (list (next-row (next-row s))))
                (eval 'lst)))
            (let (lst (list (prev-diagl s)(prev-diagr s)(prev-row s)))
              (if (= "4" (row s))
                (append lst (list (prev-row (prev-row s))))
                (eval 'lst))))))
      (eval nil))))

Note the three evals used simply to return the list I want. I would hope that there is a better way. Trouble is I don't know it! Obviously I could wrap everything in (catch and then use (throw but that seems a kludge.



So how do you handle this kind of thing?