REBOL [
    Title: "Directory list"
    Purpose: {Find all the directories in the current directory
    and return them in a block.}
]

;; [---------------------------------------------------------------------------]
;; [ This is a function written for a specific purpose of locating all the     ]
;; [ directories in the current directory so that we then could go into        ]
;; [ each of those directories and do things.  The function locates everything ]
;; [ in the current directory, deletes everything that is not a directory,     ]
;; [ and returns the result in a block.                                        ]
;; [---------------------------------------------------------------------------]

DIR-LIST: func [
    /local ITEMLIST
] [
    ITEMLIST: copy []
    ITEMLIST: read %.
    while [not tail? ITEMLIST] [
        either dir? first ITEMLIST [
            ITEMLIST: next ITEMLIST
        ] [
            remove ITEMLIST
        ]
    ]
    ITEMLIST: head ITEMLIST
    return ITEMLIST
]

;;Uncomment to test
;LST: DIR-LIST
;foreach ITEM LST [print ITEM]
;halt