I'm stucked in generating auto increment keys for a hash tree. Here's my approach:
Code: Select all
(new Tree 'products)
(define (highest-key tree)
(if-not (empty? (tree))
(begin
(println "Tree is not empty.")
(string (inc (integer (first (last (sort (tree)) <)))))
)
(begin
(println "Tree is empty.")
(string (integer 1))
)
)
)
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products (highest-key products) "hello")
(products)
Code: Select all
(("1" "hello") ("10" "hello") ("2" "hello") ("3" "hello") ("4" "hello") ("5" "hello")
("6" "hello")
("7" "hello")
("8" "hello")
("9" "hello"))
Cheers
Hilti