On Tue, Jul 08, 2008 at 09:33:02AM +1000, konrad Zielinski wrote:
> "        Flesch Index: 93.1/100"
> what I want to get out is the 93.1

If it just for parsing (scraping) the input stream, it is very simple:

   (from "Flesch Index:")
   (format (till "/" T) 1)

This will return a scaled number.


> and assign it to a local variable
> called Flesch.

Here an example to read the value and double it, and format it again:

   (in "file"
      (from "Flesch Index:")
      (let Flesch (format (till "/" T) 1)
         (format (* 2 Flesch) 1) ) )


Or should the variable 'Flesch' also be read from the file? Then
it is better to use 'intern', or simply 'read'

   : (in "file"
      (let (Var (read)  Val (prog (from "Index:") (format (till "/" T) 1)))
         (set Var Val)
         (println Var (format Val 1) (val Var)) ) )
   Flesch "93.1" 931
   -> 931


> later lines like to do things in a completly different way such as:
> 
> "        9 words, average length 3.89 characters = 1.00 syllables"

It depends what you want to do, and what assumptions you can make for
the input data. Let's assume you know the positions and scale of all
numbers:

   : (in "file"
      (skip)  # Skip leading white space
      (let Line (split (line) " ")
         (list
            (format (pack (car Line)))
            (format (pack (get Line 5)) 2)
            (format (pack (get Line 8)) 2) ) ) )
   -> (9 389 100)


The same can be achieved with 'from' and 'read' instead of 'format'

   : (in "file"
      (make
         (link (read))
         (from "length")
         (link (scl 2 (read)))
         (from "characters =")
         (link (scl 2 (read))) ) ) 
   -> (9 389 100)

There are many other possible solutions, though.

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]

Reply via email to