development release newLISP v. 9.3.6

Started by Lutz, April 01, 2008, 02:14:24 PM

Previous topic - Next topic

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/">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

#1
Few software projects could boast such speed in their report-fix cycles ;))

Thank you

newdep

#2
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

#3
Hi Lutz,



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



norman.
-- (define? (Cornflakes))

newBert

#4
Hello,



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


(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:
(set 'lst (invent))
(pop-assoc (lst "apples"))
(println lst) ; -> (("bananas" 312) ("oranges" 274) ("pears" 137))

instead of:
(pop-assoc ((invent) "apples"))

The following attempt doesn't work either:
(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? ;-)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

Lutz

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



http://www.newlisp.org/downloads/newlisp_manual.html#pop-assoc">http://www.newlisp.org/downloads/newlis ... #pop-assoc">http://www.newlisp.org/downloads/newlisp_manual.html#pop-assoc



to remove hash associations, just set them to nil:


> (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:


> (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:


> (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:



; 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

#6
Quote from: "Lutz"To remove hash associations, just set them to nil

Ah, and it's even simpler than I thought :)


Quote from: "Lutz"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 ...  
Quote from: "Lutz"... just for convenience, its a practical way to convert a hash namespace into an association list and vice versa


Many thanks

:)
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>