-
-
Notifications
You must be signed in to change notification settings - Fork 111
Library
Oleh Krehel edited this page May 8, 2015
·
1 revision
The library for building a decision tree consists of just two functions: avy-subdiv
and avy-tree
.
The first function, avy-subdiv
, tries to split a number in terms of the base in a way that the most leaves have the lowest level:
(avy-subdiv 42 5)
;;=> (5 5 5 5 22)
(avy-subdiv 42 4)
;;=> (4 6 16 16)
(avy-subdiv 42 3)
;;=> (9 9 24)
(avy-subdiv 42 2)
;;=> (16 26)
The returned list of numbers is the candidates distribution per branch.
And here's an example of what avy-tree
produces:
(avy-tree
'("Acid green" "Aero blue" "Almond" "Amaranth"
"Amber" "Amethyst" "Apple green" "Aqua"
"Aquamarine" "Auburn" "Aureolin" "Azure"
"Beige" "Black" "Bronze" "Blue" "Burgundy" "Candy apple red")
'(1 2 3 4))
;;=>
((1 (1 leaf . "Acid green")
(2 leaf . "Aero blue")
(3 leaf . "Almond")
(4 leaf . "Amaranth"))
(2 (1 leaf . "Amber")
(2 leaf . "Amethyst")
(3 leaf . "Apple green")
(4 leaf . "Aqua"))
(3 (1 leaf . "Aquamarine")
(2 leaf . "Auburn")
(3 leaf . "Aureolin")
(4 leaf . "Azure"))
(4 (1 leaf . "Beige")
(2 leaf . "Black")
(3 leaf . "Bronze")
(4 (1 leaf . "Blue")
(2 leaf . "Burgundy")
(3 leaf . "Candy apple red"))))
I think the library turned out to be pretty clean, since it knows nothing of points, buffers or overlays, and imposes no restrictions on the type of leaf items and keys.