Recent posts

#21
newLISP in the real world / Re: rotate bug?
Last post by cameyo - January 09, 2024, 09:47:22 AM
Thanks!!
#22
newLISP in the real world / Re: rotate bug?
Last post by vashushpanov - January 09, 2024, 01:50:57 AM
in file nl-liststr.c replace string
if (length <= 1 || count == 0 || length == labs(count))
to
if (length <= 1 || count == 0 || length == labs(count) || count % length == 0)

and recompile NewLisp
#23
newLISP in the real world / rotate bug?
Last post by cameyo - December 19, 2023, 05:23:26 AM
Maybe a bug of "rotate" when negative rotations and absolute rotations multiple of length of list.

(rotate '("1" "A" "B" "2") 8)
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") -8)
;-> ("1") ;ERROR
(rotate '("1" "A" "B" "2") 12)
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") -12)
;-> ("1") ;ERROR

Workaround:
(rotate lst (- (% r (length lst))))
(rotate '("1" "A" "B" "2") (- (% 12 4)))
;-> ("1" "A" "B" "2")
(rotate '("1" "A" "B" "2") (- (% 8 4)))
;-> ("1" "A" "B" "2")

#24
newLISP in the real world / Reverse lowercase to uppercase...
Last post by cameyo - December 18, 2023, 10:58:19 AM
Given a string, how to reverse lowercase to uppercase and vice versa with a "regex"?
#25
newLISP and the O.S. / Re: Build newLISP for win10 64...
Last post by IVShilov - December 16, 2023, 11:13:24 AM
Thank you!
#26
newLISP and the O.S. / Re: Build newLISP for win10 64...
Last post by cameyo - December 15, 2023, 07:11:18 AM
I've been busy a little longer...
But today I compiled newLISP 10.7.6
See instructions here:
https://github.com/cameyo42/newLISP-Note/blob/master/97-appendici.lsp#L3767
I only compiled the utf8-ffi version and did few tests.
Ciao
#27
newLISP and the O.S. / Re: Build newLISP for win10 64...
Last post by cameyo - November 20, 2023, 09:58:09 AM
Hello IVShilov,
I'm a little busy right now.
I'll try to compile newlisp 64 bit next week (I hope).
Ciao
#28
newLISP in the real world / Re: Reading keyboard input
Last post by IVShilov - November 18, 2023, 08:54:54 AM
Found solutions.

Quote1) F1 (code 0 59) because 0 is default result of (read-key true) means "no key pressed", and IMHO it must return nil;
2) UTF8 non-onebyte char - leads to infinite loop and crash.
This two problems block for me creating enhanced REPL.

Explanation of problem:
(import "msvcrt.dll" "_getch")
(import "msvcrt.dll" "_kbhit")
(exec "chcp 65001")
(setq n 0)
(while (< n 7)
    (if (= 1 (setq k (_kbhit) ))
(println (++ n) ":" k ":" (_getch) ":" (_kbhit))
(setq n 0)
)
    )
  )
1:1:13:0   <----------- ENTER, one catch, code 13, and kbhit returns 0
1:1:224:1  <----------- press UP: two codes: 224 and next 72
2:1:72:0
1:1:0:1    <----------- press F1: two codes: first 0, kbhit still returns 1
2:1:59:0   <-------------------------------- second: 59, after that kbhit returns 0
1:1:145:1  <----------- enter "ё": first code 209 was disappear, getch return second: 145
2:1:145:1  <----------- AND kbhit still returns 1:
3:1:145:1
4:1:145:1
5:1:145:1
6:1:145:1
7:1:145:1
1
> ё        <----------- and ё somehow printed by default newlisp REPL
Solutions is:
1) for catch F1-F12: import kbhit and check if key was pressed;
2) UTF8 in cmd.exe: DO NOT (exec "chcp 65001"), because it enable UTF8 input AND output.
It's hard to even imagine keyboard with button for every char in UTF8 set, so it will be quite enough to enable UTF8-output only:
(import "kernel32.dll" "SetConsoleOutputCP")
(import "kernel32.dll" "GetConsoleOutputCP")
> (SetConsoleOutputCP 866) (GetConsoleOutputCP) (char 937)
1
866
"╬й"          <----------- FAIL
> (SetConsoleOutputCP 65001) (GetConsoleOutputCP) (char 937)
1
65001
"Ω"           <----------- SUCCESS
> (import "kernel32.dll" "GetConsoleCP")
GetConsoleCP@CB3855F0
> (GetConsoleCP)
866           <----------- this is INPUT codepage
> (GetConsoleOutputCP)
65001         <----------- this is OUTPUT codepage
>
More info here
Complete solution is in use "Win32 Console API".
#29
newLISP and the O.S. / Re: Build newLISP for win10 64...
Last post by IVShilov - November 12, 2023, 10:59:24 PM
Maybe in 2019 it was so simple,but in 2023 it is not :)
TDM have no ls, rm utilities, so I cannot do a "./configure" or "make clean".
MSYS have, but it not appropriate for building.

Can somebody explain step by step what I have to do to build newlisp from souce?

First: install TDM-GCC, ok, what next?
#30
newLISP and the O.S. / Re: Windows clipboard
Last post by cameyo - November 07, 2023, 06:29:32 AM
Thanks!