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

#1
newLISP newS /
August 31, 2009, 01:11:14 PM
Quote from: "Sammo"Work for me after replacing the ASCII 92 character you used as a single quote with a bonafide single quote character ASCII 27.  Here is the working code:



(define number-list '(100 300 500 701 900 1100 1300 1500))

(dolist (n number-list (!= (mod n 2) 0))

(println (/ n 2)))


Thanks Sammo ,



That works now

still I am confused which function is executed first in this code,



(dolist (n number-list (!= (mod n 2) 0))



regards
#2
newLISP newS /
August 31, 2009, 12:24:16 PM
Quote from: "ale870"In that example it seems there are some minor but relevant syntax errors.

I didn't see the original example, so you could cheeck if you copied it well.

Can you tell m exaclty where you found it?




That example can be found in the 'Introduction to newLISP' tutorial , which is here http://www.newlisp.org/index.cgi?Documentation">//http://www.newlisp.org/index.cgi?Documentation .Please look in the section; looping /an escape route is available



As curmullion mentioned , I have missed a opening paranthesis. The correct code would be ,



(define number-list '(100 300 500 701 900 1100 1300 1500))

(dolist (n number-list (!= (mod n 2) 0))

(println (/ n 2)))




when this code is run in newLISP shell , an error is returned



>

nil

ERR]




Thanks
#3
newLISP newS /
August 30, 2009, 04:22:29 AM
Thanks ale870 for the detailed reply.



I am bit confused on this code given in the tutorial .



define number-list '(100 300 500 701 900 1100 1300 1500))

(dolist (n number-list (!= (mod n 2) 0)) ; escape if true

(println (/ n 2)))




In the previous section of the tutorial ,

(dolist (n number-list ))

it's said n is a loop variable and it takes a value from list for each iteration.



But in this case, I am wondering which function will execute first .

(dolist (n number-list (!= (mod n 2) 0))



If it is (!= (mod n 2) 0) , how is 'n' getting the value from the list .



Thanks
#4
newLISP newS /
August 28, 2009, 12:16:37 PM
Quote from: "HPW"
QuoteIs there anyway that I can stop the return value getting printed.


You can use: (silent(println "Hello World"))


Magic , That is working . Can you please explain , what happens to the returned value now when you get a chance?

Does every function is newLISP return a value?



I am very new to LISP , that's why asking all these silly questions .



Thanks
#5
newLISP newS /
August 28, 2009, 12:11:50 PM
Quote from: "ale870"
Quote from: "dvebc"
Quote from: "Lutz""C:path-file" will not work, because the "" is a special (escape) character. The best for file-path names is, to use the forward slash instead, like in "C:/path-file". The forward slash will work on both: Win32 an Unix operating systems. Or you could escape the "" using "C:\path-file".


Many thanks Lutz ,



I tried the foreward slash "/" and it doesnt work for me . I will try the "" now.



Regards


Does not work? It's strange. Can you send me the code you are using?


Sorry , I think I made some mistakes yesterday , "Late nights = No Brain".

Tried it forward slash / again and it's working . Double back slash \ is also working .



Many Thanks
#6
newLISP newS /
August 28, 2009, 05:29:49 AM
Quote from: "Lutz""C:path-file" will not work, because the "" is a special (escape) character. The best for file-path names is, to use the forward slash instead, like in "C:/path-file". The forward slash will work on both: Win32 an Unix operating systems. Or you could escape the "" using "C:\path-file".


Many thanks Lutz ,



I tried the foreward slash "/" and it doesnt work for me . I will try the "" now.



Regards
#7
newLISP newS /
August 28, 2009, 05:28:11 AM
Quote from: "cormullion"Hi! Every expression in newLISP returns a value. (print "Hello World") is an expression, and it returns the value "Hello World". You'll see this in the terminal, just as you'll see the result of an expression such as (+ 2 2). However, the print function  has a side-effect: it prints the string to the current output device. This may also be the terminal. If it is, you'll see both the 'printing' action and the return value of the expression.



It isn't always true that printing goes to the screen, though:


> (println "hello world")
hello world
"hello world"
> (device (open "myfile" "write"))
3
>
> (println "hello world")
"hello world"
> (close (device))
true
> (println "hello world")
hello world
"hello world"
>


If you look in myfile, you'll see it contains the printing, because (device ...) redirected it. You saw the return values of each expression as usual, though.



Also:


> (read-file "myfile")
"hello worldn"
>


shows that (read-file) worked as expected. You don't need (println), unless sending output to a file... I think "C:path-file" should work if that really is the exact name of the file.






Thanks a mil cormullion ,



That helps a lot .Is there anyway that I can stop the return value getting printed.



And is there any IDEs or editors , which I can configure newLISP .



Regards
#8
newLISP newS / newLISP 10.1.2 issues
August 27, 2009, 02:36:12 PM
Hi all,



I am new in this forum.

Installed newLISP in my winxp machine and I started learning it with the help of 'Introduction to newLISP'.



One of my problem is with the print function



(print "Hello World")

 result comes like this --  Hello World"Hello World"

it's repeating.



Another issue is

(println(read-file "c:path-file")) gives a nil eventhough the file exist.



I wonder anyone here can help me on this



Many Thanks