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

#181
newLISP newS / Re: Ask info about newLISP
January 03, 2019, 09:45:42 AM
Thanks Hans-Peter.

I have seen newlisp 10.7.5 in the development folder...

A reply from Lutz can solve my question :-)



cameyo
#182
newLISP newS / Ask info about newLISP
January 03, 2019, 04:57:10 AM
I'd like to get some infos about the development of newLISP.

When will be out a new version?

Thanks.
#183
Take a look here:

http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=4940">//http://www.newlispfanclub.alh.net/forum/viewtopic.php?f=9&t=4940

Keep in mind that windows 7 is worse than windows 10 :-(
#184
(define (f converse-rate-list)
  (local (rate) (setq rate converse-rate-list))
)

I am almost sure that this is not what you are searching for...  :-)

cameyo
#185
newLISP in the real world / Re: Notepad++ bundle
November 29, 2018, 01:32:23 PM
Update:

1) Shortcut (Ctrl + F8) to evaluate expression inside notepad ++ (get the result in notepad++ console)

2) Shortcut (Ctrl + Alt + =) to insert:

[cmd]



[/cmd]



cameyo
#186
newLISP in the real world / Re: factor-group function
November 28, 2018, 10:41:51 PM
Thanks Ralph.

I am really enjoying newLisp :-)

cameyo
#187
newLISP in the real world / factor-group function
November 25, 2018, 01:45:59 AM
To solve a project euler problem i have written this factor-group function:
(define (factor-group x)
  (letn (fattori (factor x)
         unici (unique fattori))
    (transpose (list unici (count unici fattori)))))

(factor-group 2000)
;-> ((2 4) (5 3))
(factor-group 232792560)
;-> ((2 4) (3 2) (5 1) (7 1) (11 1) (13 1) (17 1) (19 1))

Do you known a better/faster way?

Thanks.



cameyo
#188
newLISP in the real world / Understand "curry" function
November 25, 2018, 01:28:10 AM
This is what I understand ...



I can map a function with multiple arguments in this way:
(map pow '(2 1) '(3 4))
;-> (8 1)

where: 8 = 2^3, 1 = 1^4

But, if the list of arguments are within a list:
(setq lst '((2 1) (3 4)))
I got an error:
(map pow lst)
ERR: value expected in function pow : '(2 1)

I use "curry" to solve this problem:
(map (curry apply pow) lst)
;-> (2 81)

where: 2 = 2^1, 81 = 3^4

Ok, transpose the list of arguments:
(map (curry apply pow) (transpose lst))
;-> (8 1)

This is equivalent to:
(map (lambda(x) (apply pow x)) (transpose lst))
;-> (8 1)

We can define a user function too:
(define (mypow lst)
  (if (null? lst) '()
      (cons (pow (nth '(0 0) lst) (nth '(0 1) lst)) (mypow (rest lst)))
  )
)

(setq lst '((2 1) (3 4)))
(mypow (transpose lst))
;-> (8 1)

Another example:
(map max '(3 5) '(2 7))
;-> (3 7)
(map (curry apply max) '((3 5) (2 7)))
;-> (5 7)
(map (curry apply max) (transpose '((3 5) (2 7))))
;-> (3 7)


Did I get it right?

cameyo

p.s. sorry for poor english...
#189
The book "A Practical Introduction to Fuzzy Logic using LISP" contains a section that explains the management of csv files (builds a simple CSV library).

The code is written in newLisp.



cameyo
#190
newLISP in the real world / Notepad++ bundle
November 21, 2018, 08:09:00 AM
Download: https://github.com/cameyo42/notepadpp-newlisp">//https://github.com/cameyo42/notepadpp-newlisp



Add newlisp syntax highlighting

Copy all the text of the file: newlisp-udl.xml

and paste it inside the section:<NotepadPlus> ... </NotepadPlus>

of the file: userDefineLang.xml (located at: c:Users<username>AppDataRoamingNotepad++)
Example
<NotepadPlus>
    <UserLang name="newLISP" ext="lsp" udlVersion="2.1">
    ...
    </UserLang>
</NotepadPlus>
   

The newlisp keywords are from primes.h (newlisp source).

The actual highlight colors are for "obsidiane" theme of notepad++.

You can change (easily) the colors as you like.



Open newlisp help from notepad++

Add the line: <Command name="newLISP Help" Ctrl="yes" Alt="yes" Shift="no" Key="112">chrome file:///C:/Program%20Files%20(x86)/newlisp/newlisp_manual.html#$(CURRENT_WORD)</Command>
inside the section: <UserDefinedCommands> ... </UserDefinedCommands>

of the file: shortcut.xml (located at: c:Users<username>AppDataRoamingNotepad++)
Example
<UserDefinedCommands>
    <Command name="newLISP Help" Ctrl="yes" Alt="yes" Shift="no" Key="112">chrome file:///C:/Program%20Files%20(x86)/newlisp/newlisp_manual.html#$(CURRENT_WORD)</Command>
   
</UserDefinedCommands>

Note: change the path to point to your newlisp help file

Now you can select a word and press Ctrl+Alt+F1 to open newlisp help file.

The shortcut is Ctrl+Alt+F1, but you can change it.



Execute newlisp code from notepad++

Download and install autohotkey (http://www.autohotkey.com">http://www.autohotkey.com).

Run the script npp-newlisp.ahk (double click it).

Run notepad++

Press Win+F12 to start newlisp REPL

Now, from notepad++, you can:

1) Execute the expression of current line pressing: Left-Shift + Enter

2) Execute a selected block of expression pressing: Right-Shift + Enter

After the execution of the expressions, notepad++ is the active application.

Note:

When selecting a block of expression be sure to begin and end the selection

with a blank line (or use [cmd] [/cmd]).

Note:

The script npp-newlisp.ahk exchange the brackets () and [] in the keyboard.

You can edit the file to disable this (you must comment two lines).

The script also enable other shortcuts... see the source.

Happy coding



cameyo
#191
newLISP in the real world / Re: Apply error message
November 18, 2018, 02:58:03 AM
Thanks.

A big help for me.



cameyo
#192
newLISP in the real world / Re: Apply error message
November 17, 2018, 12:05:49 PM
"transpose" works like i want :-)

But is the expression wrong logically or syntactically?

Why  "apply" does not receive a list?

Thanks again



cameyo
#193
newLISP in the real world / Apply error message
November 17, 2018, 07:03:06 AM
The following expression give me an error:
(apply map list '((a 1) (b 2) (c 3)))
QuoteERR: list expected in function apply : list@4095B0

Instead, I wish the output was:
Quote((a b c) (1 2 3))

Can someone help me?

Thanks



cameyo
#194
newLISP in the real world / Re: FUNCALL and GETDEF
October 26, 2018, 11:58:55 PM
Hi newbert,

I have found these functions in an old article on Lisp (to define a function it use DE, maybe Portable Standard Lisp).

GETDEF gets the definition of a function.

Thanks for infos.
#195
newLISP in the real world / FUNCALL and GETDEF
October 26, 2018, 12:29:24 AM
Hi all,

i'm looking for the functions FUNCALL and GETDEF.

Are there equivalent functions in newLisp?

Sorry for dumb question...i'm a newbie.

cameyo