development release newLISP v. 9.3.6

Notices and updates
Locked
Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

development release newLISP v. 9.3.6

Post by Lutz »

* bug fixes for the new namespace hash functions

* changes and refinements in the 'wait-pid' functionality

* default values in 'lookup'


files and changes notes: http://newlisp.org/download/development/

ps: Mac Users, click on uninstall first if experiencing difficulties to insta;;. The script also removes the receipt for newLISP in /Library/Receipts

lithper
Posts: 39
Joined: Sun Feb 24, 2008 12:58 am
Location: USA

Post by lithper »

Few software projects could boast such speed in their report-fix cycles ;))
Thank you

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Lutz, You're going fast in the 9.3.xx series...
Im out for 3 months and I already need extra classes to keep up here ;-)
-- (define? (Cornflakes))

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Hi Lutz,

The makefile_linux64 is not embeded inside the Makefile? Is there a reason for it?

norman.
-- (define? (Cornflakes))

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Dictionnary in NL-9.3.6

Post by newBert »

Hello,

How to delete an association in a dictionnary (newLisp-3.9.6)?

Code: Select all

(define invent:invent)
(map invent '("apples" "bananas" "oranges" "pears") '(430 312 274 137))
(println (invent)) ;-> (("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137))
To remove an association I must do this:

Code: Select all

(set 'lst (invent))
(pop-assoc (lst "apples"))
(println lst) ; -> (("bananas" 312) ("oranges" 274) ("pears" 137))
instead of:

Code: Select all

(pop-assoc ((invent) "apples"))
The following attempt doesn't work either:

Code: Select all

(define (remove ctx key)
   (pop-assoc (ctx key))) 
   
(remove (invent) "apples")
(println (invent)) ; -> (("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137))
Where do I err? ;-)
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

pop-assoc is for association lists not hashes. See here:

http://www.newlisp.org/downloads/newlis ... #pop-assoc

to remove hash associations, just set them to nil:

Code: Select all

> (invent "apples" nil)
nil
> (invent)
(("bananas" 312) ("oranges" 274) ("pears" 137))
> 

The list you get when executing (invent) is an association list, but the method used to created hash associations stores the key-values pairs in a namespace:

Code: Select all

> (symbols invent)
(invent:_bananas invent:_oranges invent:_pears invent:invent)
> 
Associations in list are a different method of dealing with associations, and you can use pop-assoc here:

Code: Select all

> (set 'Alist '(("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137)))
(("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137))

> (pop-assoc (Alist "apples"))
("apples" 430)

> Alist
(("bananas" 312) ("oranges" 274) ("pears" 137))
> 
Perhpas what confuses you, is the fact that in namespace hashing (invent) recturns an association list. This is just for convenience, its a practical way to convert a hash namespace into an association list and vice versa:

Code: Select all

; and association list

(set 'Alist '(("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137)))

; convert it into a hash namespace

> (define invent:invent)

> (invent Alist) 
invent

> (invent)
(("apples" 430) ("bananas" 312) ("oranges" 274) ("pears" 137))

> (invent "bananas") 
323
>
So you can convert one data representation into the other. Namespace hashes are good for big data quantities, e.g. maintaining thousands or millions of key-value pairs. For a hundred or less, old fashioned association lists are faster.

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

Lutz wrote:To remove hash associations, just set them to nil
Ah, and it's even simpler than I thought :)
Lutz wrote:Perhpas what confuses you, is the fact that in namespace hashing (invent) recturns an association list.
Yes and, for my purpose, association lists are quite sufficient and more convenient. But I'll remember that hash tables are ...
Lutz wrote:... just for convenience, its a practical way to convert a hash namespace into an association list and vice versa
Many thanks
:)
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

Locked