How to search for a string sequence in a file a rewrite it???

Hal Daume III hdaume@ISI.EDU
Wed, 12 Mar 2003 16:05:13 -0800 (PST)


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
>