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

#1
hi,



I have OSX with newlisp 10.6.0 and newLISP-GS v.1.63 installed with homebrew.

 

I tried the button-demo.lsp from http://www.newlisp.org/guiserver/guiserver.lsp.html">http://www.newlisp.org/guiserver/guiserver.lsp.html and ran into an error.



The line


(gs:set-color 'ColorPanel (random) (random) (random))


resulted in a message "Could not invoke method set-color with MAIN:ColorPanel" in a gui dialog.



Adding (println (random)) to the code printed something like:

0,84018771715471



I could fix the problem by either setting the locale to "en_US" (from "de_DE.UTF-8") or by converting the random number to a string with "," replaced by ".":



; use prandom instead of random:
(define (prandom)
(replace "," (string (random)) ".")
)


Shouldn't the locale be irrelevant as there's no output in button-demo.lsp?

What I mean is.. shouldn't the random float be just a value -- nothing that has comma or period when interpreting its value?



(Is there an implicit conversion to a string where the locale plays its role? Is that useful?)



Curious

 t3o
#2
Hi Lutz



thanks so far.



I know that the following is not "Build failed" any more but I started this second diskussion above.



What about (random x y) returning the same number with each program run?

Is that wanted behaviour? (and: is it a good test?)



Here's a small test program:



t3o@pux:build/newlisp/newlisp-10.6.0% cat random | nl

     1   (println (random 10 10000))

     2   (exit)



t3o@pux:build/newlisp/newlisp-10.6.0% for i in 1 2 3 4; do ./newlisp random ; done

8411,8771715471

8411,8771715471

8411,8771715471

8411,8771715471



Another test:



t3o@pux:build/newlisp/newlisp-10.6.0% cat random2 | nl

     1   (println (random 10 10000))

     2   (println (random 10 10000))

     3   (println (random 10 10000))

     4   (exit)



And it prints the same three "random" numbers on each run:



t3o@pux:build/newlisp/newlisp-10.6.0% for i in 1 2 3 4; do ./newlisp random2 ; done

8411,8771715471

3953,82926819093

7840,99223758606

8411,8771715471

3953,82926819093

7840,99223758606

8411,8771715471

3953,82926819093

7840,99223758606

8411,8771715471

3953,82926819093

7840,99223758606



That reminds me of http://www.xkcd.com/221/">http://www.xkcd.com/221/ :-)



I am still new to newlisp but from my > 30 year programming experience point of view I did not expext to get the same three numbers on each program run..



Greetings

 t3o
#3
When running the test again I get the same numbers all the time:



6,24444261148445e+48   6,24444261148445e+48 0



I expected to get a different number on each call of (set 'f (pow (random 10 100) (+ 15 (rand 50)))) but probably I do not know enough about newlisp.



And... the test says 0 is bad. But an error of 0 ist the best you can get.. (not?)



t3o
#4
Hi Lutz



t3o@pux:build/newlisp/newlisp-10.6.0% ./newlisp qa-specific-tests/qa-bigint

6,24444261148445e+48   6,24444261148445e+48 0

>>>>> ERROR in big integer/float conversion



t3o@pux:build/newlisp/newlisp-10.6.0% cat /proc/cpuinfo | grep "model name"

model name   : AMD E1-2500 APU with Radeon(TM) HD Graphics

model name   : AMD E1-2500 APU with Radeon(TM) HD Graphics    



t3o@pux:build/newlisp/newlisp-10.6.0% uname -a

Linux pux 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux



Hope that helps

t3o
#5
Hi,



adding the two typedefs helped to make 10.0.6 compile from source without errors on 14.04.



But I get an error when doing "make test":



...

>>>>> Time per proxy trip: 70 micro seconds

>>>>> Message API tested SUCCESSFUL

>>>>> ERROR in big integer/float conversion

make[1]: *** [check] Error 255





regards

 t3o
#6
hi and thanks for your answers!



My fault (or one of mine) was to think a call to "read-line" would result in a list of lines that I could process with "map": I wanted to map a shrink function on each of the lines.



Now I know that a call to "read-line" results in only a single line read. Hence its name ;-)



Is the code below the best (shortest; most newlispish) solution for my problem to print only a half of each line of input?

#!/usr/bin/newlisp
(while (read-line)
(println (slice (current-line) (div (length (current-line) ) 2)))
)

; echo -e "foofoonblablan"| ./echo.lsp


thanks

  t3o
#7
hi,



I am new to newlisp and I managed to read and process lines from stdin this way:


(while (read-line)
(println (slice (current-line) (div (length (current-line) ) 2)))
)


= print half of each line. A friend needed that.



I would like to do this by calling a function for each line of input but I cannot get it running. I thought of something like this:


(map (fn(line)
    (println ..)
    (read-line)
)


What is wrong with that?



Thanks

   t3o