Note that there are some explanatory texts on larger screens.

plurals
  1. POhaskell word searching program development
    primarykey
    data
    text
    <p>hello I am making some word searching program</p> <p>for example </p> <p>when "text.txt" file contains "foo foos foor fo.. foo fool" </p> <p>and search "foo"</p> <p>then only number 2 printed</p> <p>and search again and again</p> <p>but I am haskell beginner </p> <p>my code is here</p> <pre><code>:module +Text.Regex.Posix putStrLn "type text file" filepath &lt;- getLine data &lt;- readFile filepath --1. this makes &lt;interactive&gt;:1:1: parse error on input `data' how to fix it? parsedData =~ "[^- \".,\n]+" :: [[String]] --2. I want to make function and call it again and again searchingFunc = do putStrLn "search for ..." search &lt;- getLine result &lt;- map (\each -&gt; if each == search then count = count + 1) data putStrLn result searchingFunc } </code></pre> <p>sorry for very very poor code </p> <p>my development environment is Windows XP SP3 WinGhci 1.0.2</p> <p>I started the haskell several hours ago sorry</p> <p>thank you very much for reading!</p> <p>edit: here's original scheme code</p> <p>thanks!</p> <pre><code>#lang scheme/gui (define count 0) (define (search str) (set! count 0) (map (λ (each) (when (equal? str each) (set! count (+ count 1)))) data) (send msg set-label (format "~a Found" count))) (define path (get-file)) (define port (open-input-file path)) (define data '()) (define (loop [line (read-line port)]) (when (not (eof-object? line)) (set! data (append data (regexp-match* #rx"[^- \".,\n]+" line))) (loop))) (loop) (define (cb-txt t e) (search (send t get-value))) (define f (new frame% (label "text search") (min-width 300))) (define txt (new text-field% (label "type here to search") (parent f) (callback (λ (t e) (cb-txt t e))))) (define msg (new message% (label "0Found ") (parent f))) (send f show #t) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload