Ooops a small error before but here is the right one. Great. I got almost everything. My problem now is: I got a function called findstr where findstr "aaaa" "zzzzz" ["xxxxaaaa","xxxaaaaxxx"] = ["xxxxzzzzz","xxxzzzzzxxx"] and then I try something like fillIn lines = do bkfilled <- (findstr str str2 lines) write bkfilled where write takes a [String] and concatenates it writing it to a file then. But I get this error saying: Expected Type: [String] Inferred Type: String In the first argument of 'write' namelly 'bkfilled' In a do expection pattern binding: write bkfilled Any idea?? I mean bkfilled is supposed to be [String] but it says it is a String, any idea why??? Best Regards Alex ----- Original Message ----- From: "Hal Daume III" <hdaume@ISI.EDU> To: "Alexandre Weffort Thenorio" <alethenorio@home.se> Cc: <haskell@haskell.org> Sent: Thursday, March 13, 2003 1:38 AM Subject: Re: How to search for a string sequence in a file a rewrite it???
Right. *Recurse* down the list. Somethign like:
foo orig_str new_str xl@(x:xs) | orig_str `isPrefixOf` xl = <something> | otherwise = x : <something>
-- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume
On Thu, 13 Mar 2003, Alexandre Weffort Thenorio wrote:
Well the problem is that the string I want to replace will usually be in the middle of a line in the text file and then is PrefixOf of no use?? Any other suggestion??
Like the text file will be similar to
abcdedjkfhlafl sajkhlabbbbsf akfhjklafjkhfk sdfasfsaasffaa
So I want to replace this bbbb in the middle there with aaaa. I could run lines on the file but from there i have no idea. I have got an idea but for it to work I need to know if there is a function that I can replace a certain Char in a string by another Char by knowing the index of this char??
Best Regards
NooK ----- Original Message ----- From: "Hal Daume III" <hdaume@ISI.EDU> To: "Alexandre Weffort Thenorio" <alethenorio@home.se> Cc: <haskell@haskell.org> Sent: Thursday, March 13, 2003 1:05 AM Subject: Re: How to search for a string sequence in a file a rewrite it???
This is how I would do it:
recurse down the input string. use isPrefixOf to check is the string youw ant to replace is at the head of the string. if it is, 'drop' the appropriate number of characters and stick the replacement string on the front. then recurse.
this should be about 3 lines of code.
-- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume
On Thu, 13 Mar 2003, Alexandre Weffort Thenorio wrote:
OK Guys. First I would like to say thanks for all the help given before. As I said I am still learning Haskell. My problem is the following:
I have a text file and somewhere in the file there is string (Let's say aaaa). So I need to find this exact string and overwrite with another string (Lets say bbbb).
I have thought a bit and couldn't find any solution, and I believe it is a piece of cake for some of you. Is there a method already implemented in haskell to do that?? Anyway thanks in advance.
Best Regards
NooK
----- Original Message ----- From: "Arthur Baars" <arthurb@cs.uu.nl> To: <haskell@haskell.org> Cc: "Norman Ramsey" <nr@eecs.harvard.edu> Sent: Wednesday, March 12, 2003 1:06 AM Subject: Re: clueless GHCI user wishes to load QuickCheck
QuickCheck is in de "util" package. You can load a package with the -package flag:
$ ghci -package util Prelude> :browse QuickCheck class Arbitrary a where { arbitrary :: Gen a; coarbitrary :: forall b. a -> Gen b -> Gen b; } arbitrary :: forall a. (Arbitrary a) => Gen a ... Prelude>:module QuickCheck
Prelude QuickCheck> :info trivial -- trivial is a variable trivial :: forall a. (Testable a) => Bool -> a -> Property
Hope this helps.
Cheers,
Arthur
On Tuesday, March 11, 2003, at 07:02 PM, Norman Ramsey wrote:
Can anyone help me figure out how to load QuickCheck into GHCI? QuickCheck is included in my Debian package, but my attempts at loading it are bootless:
Prelude> :load QuickCheck can't find module `QuickCheck' Prelude> :load util/QuickCheck can't find module `util/QuickCheck' Prelude> :info syntax: `:i <thing-you-want-info-about>' Prelude> :load util/QuickCheck.hi can't find module `util/QuickCheck.hi' Prelude> :load /usr/lib/ghc-5.02.2/imports/util/QuickCheck.hi can't find module `/usr/lib/ghc-5.02.2/imports/util/QuickCheck.hi' Prelude> :load /usr/lib/ghc-5.02.2/imports/util/QuickCheck can't find module `/usr/lib/ghc-5.02.2/imports/util/QuickCheck' Prelude>
Any advice, anyone?
Norman _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell