#!/usr/bin/newlisp

#
# hash - benchmark
# create i=1->n symbols with value i
# count all exsiting symbols in reverse
#
# newLISP does not have hashtables but can
# simlate hashes with symbols
#

(context 'HASH) ; create hash container
(context 'MAIN) ; go back to MAIN context

(set 'n (integer (main-args 2)))

(for (i 1 n)
	(set (sym (format "_%x" i) HASH) i) )

(set 'cnt 0)
(for (i n 1)
	(if (sym (format "_%d"  i) HASH nil) (inc 'cnt)))

(println cnt)

(exit)



syntax highlighting with newLISP and syntax.cgi