[Cook] Enumerating leaf directories

Reuben Thomas rrt at sc3d.org
Sat Mar 3 10:17:49 EST 2007


Here I am, attacking my problem step by step!

Step 1: I need to find my sources. They are, effectively, the leaf 
directories of the tree. How best to enumerate them? Two hints:

1. I don't think find can do it unaided.

2. If you get a complete list of directories, and sort it, you can then use 
the trick that a directory is a leaf if it is either the last in the list, 
or is not a prefix of the following directory.

In case it's not obvious: I know how to solve this problem (the above *is* a 
solution), but I'm clueless how best to express it in Cook. In the worst 
case, I can just write an external script to make the list, but I imagine 
there's a better way to do it in Cook.

-- 
http://rrt.sc3d.org/ | free, a.  already paid for (Peyton Jones)



More information about the Cook-users mailing list