Hi,

following function is program is not working as I expect

(de read-words (file-name)
  (in file-name
        (let (res '())
          (until (eof)
                (setq res (cons (line T) res)))
              (uniq res))))

(de count-words (words acum)
        (for word words
            (put acum word (inc (or (get acum word) 0)))))


(de main ()
        (let (acum (new))
          (for fname (argv)
                   (count-words (read-words fname) acum))
          (show acum)))

====

say I have a file "called data" with the word orange on one line

if i run: p cw.l - data data

I expect for show to do somthing like:

$385555801 NIL
   "orange" 2

Instead I get
$385555801 NIL
   "orange" 1
   "orange" 1

I don't understand why two invocations of (read T) are returning two
symbols which look the same but are not equal. Its somthing
 to do with dynamic scoping how do I get arround it. The goal is to
count the number of files a particular word appears in.
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to