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

#1
In the manual ( http://www.newlisp.org/downloads/newlisp_manual.html#device">http://www.newlisp.org/downloads/newlis ... tml#device">http://www.newlisp.org/downloads/newlisp_manual.html#device ), stderr is not mentioned.

I think 2 is the stderr.



Test code (test.lsp):
(write-line 2 "stderr")
(println "stdout")
(exit)


newlisp test.lsp > out.txt
Then, "stderr" is printed to the screen. "stdout" is printed to the file.



Would you please change the manual like so:
Quoteint-io-handle is an I/O device number, which is set to 0 (zero) for the default STD I/O pair of handles, 0 for stdin and 1 for stdout.

=>
Quoteint-io-handle is an I/O device number, which is set to 0 (zero) for the default STD I/O pair of handles, 0 for stdin, 1 for stdout and 2 for stderr.
#2
It is intended. See http://www.newlisp.org/downloads/newlisp_manual.html#string">//http://www.newlisp.org/downloads/newlisp_manual.html#string


QuoteTranslates into a string anything that results from evaluating exp-1—. If more than one expression is specified, the resulting strings are concatenated.


(string 'hello)          → "hello"
(string 1234)            → "1234"
(string '(+ 3 4))        → "(+ 3 4)"
(string (+ 3 4) 8)       → "78"
(string 'hello " " 123)  → "hello 123"


I suggest using apply as follows:
> (apply string '("a" "b" "c"))
"abc"
#3
Anything else we might add? / Re: Strange reader
August 31, 2016, 01:50:28 AM
Hi, Lutz.



Speed efficiency for read? or for eval? If it is for read, then I agree. But if it it not, I suggest putting preprocessing stage between read and eval stages. Then the symbols lambda, lambda-macro, fn and fn-macro can be used in a user land.
#4
Anything else we might add? / Strange reader
January 10, 2016, 08:56:08 PM
I think special processing for lambda and fn is done too early. The reader should preserve the symbols as is.


> 'lambda

ERR: invalid lambda expression : "lambda"
> 'fn

ERR: invalid lambda expression : "fn"
> 'a
a
> (quote lambda)

ERR: invalid lambda expression : " lambda)"
> (fn (x) x)
(lambda (x) x)
> '(fn (x) x)
(lambda (x) x)
> (legal? "fn")
true
> (legal? "lambda")
true
> (sym "fn")
fn
#5
Anything else we might add? / Typo in manual
August 18, 2014, 06:44:09 PM
define-macro | http://www.newlisp.org/downloads/newlisp_manual.html#define-macro">http://www.newlisp.org/downloads/newlis ... fine-macro">http://www.newlisp.org/downloads/newlisp_manual.html#define-macro



Since v.10.5.8, newLISP also as expansion macros using macro.



->



Since v.10.5.8, newLISP also has expansion macros using macro.



I find expansion macros very useful. ^^
#6
In http://www.newlisp.org/code/modules/">//http://www.newlisp.org/code/modules/



Module: zlisp.lsp

-> Module: zlib.lsp



In http://www.newlisp.org/code/modules/zlib.lsp.html">//http://www.newlisp.org/code/modules/zlib.lsp.html



Module: zlisp.lsp

-> Module: zlib.lsp



sepcific

-> specific
#7
newLISP in the real world / Re: Thousand's separator
November 08, 2013, 01:06:05 AM
One-liner:



(define (format1000 n)
(append (sgn n "-" "" "") (reverse (join (explode (reverse (string (abs n))) 3) ","))))
(format1000 123456789)
(format1000 -123456789)
#8
newLISP in the real world / Re: Thousand's separator
November 04, 2013, 07:26:51 PM
My attempt:



>
(define (format1000 n)
  (setq s (reverse (string n)))
  (setq acc "")
  (for (i 0 (dec (length s)))
    (when (and (> i 0) (zero? (% i 3)) (number? (int (s i))))
      (setq acc (append acc ",")))
    (setq acc (append acc (s i))))
  (reverse acc))
> (format1000 123456789)
"123,456,789"
> (format1000 -123456789)
"-123,456,789"
#9
newLISP and the O.S. / Re: make on AIX 5.3
October 30, 2013, 06:27:38 PM

make -f makefile_aixLP64_utf8_gcc

./newlisp
newLISP v.10.5.4 64-bit on AIX IPv4/6 UTF-8, options: newlisp -h

> (+ 1 2)
3
#10
Thank you for your reply!



Oh, the documentation.. It is in the examples. I think it should go to the main description. ^_^



; only 2 arguments are allowed in big integer operations

; apply with reduce parameter 2 guarantees 2 args at a time

; sequence itself does not take big integers, before using

; apply, the sequence is converted with bigint
#11
arithmetic operators + - * / accept only 2 http://www.newlisp.org/downloads/newlisp_manual.html#big_int">bigint arguments?



> (apply * (dup 2 10))

1024

> (* 2L 2L 2L)

4L

> (apply * (dup 2L 10))

4L

> (apply * (dup 2L 10) 2)

1024L



I think it is not consistent. cf.

> (* 2 2 2)

8
#12
I find it hard to use in the current requirement (Multiline expressions can be entered by entering an empty line first. http://www.newlisp.org/downloads/newlisp_manual.html#multiline">http://www.newlisp.org/downloads/newlis ... #multiline">http://www.newlisp.org/downloads/newlisp_manual.html#multiline).



I suggest a new method: Wait evaluation until all parentheses and quotes are matched.



Almost all modern Lisps (Racket, Clojure, etc.) use this method.

Racket:

> (displayln
3)
3
>

Also in Paren (My Lisp implementation): https://bitbucket.org/ktg/paren">https://bitbucket.org/ktg/paren

Paren:

> (prn
  3)
3
 : nil
>


You can see how it works. https://bitbucket.org/ktg/paren/src/50406c0226d1bd728620a90b0c7a2d1bedb73be8/libparen.cpp?at=master#cl-906">https://bitbucket.org/ktg/paren/src/504 ... ter#cl-906">https://bitbucket.org/ktg/paren/src/50406c0226d1bd728620a90b0c7a2d1bedb73be8/libparen.cpp?at=master#cl-906

   // read-eval-print loop
    void paren::repl() {
        string code;
        while (true) {
            if (code.length() == 0) prompt(); else prompt2();
            string line;
            if (!getline(cin, line)) { // EOF
                eval_print(code);
                return;
            }
            code += 'n' + line;
            tokenizer t(code);
            t.tokenize();
            if (t.unclosed <= 0) { // no unmatched parenthesis nor quotation
                eval_print(code);
                code = "";
            }
        }
    }
#13
newLISP Graphics & Sound / Sweep second clock in newLISP
November 06, 2012, 08:12:14 AM
Hello,



I have made a clock program in newLISP.



http://steloflute.tistory.com/entry/newLISP-SweepSecond">//http://steloflute.tistory.com/entry/newLISP-SweepSecond



How do you remove flickering?