hi
I have a matching problem... I am wanting to identify whether or not a string
is an opening substring of another (ignoring leading spaces). I have this:
word is a single word and str is a string.
match :: String -> String -> (Bool, String)match word str |
if removeSpace s
Just remove that if. What comes after | is already a conditional.
Luke
On Dec 6, 2007 7:03 AM, Ryan Bloor <[EMAIL PROTECTED]> wrote:
>
> hi
>
> I have a matching problem... I am wanting to identify whether or not a
> string is an opening substring of another (ignoring leading spaces). I have
>
Oops, not quite. "otherwise ==" should be "otherwise =". Looks like
you already go this from the first one, but guard syntax looks like:
defn
| cond1 = ...
| cond2 = ...
| ...
| otherwise = ...
(otherwise is not actually necessary; it is just a synonym for True)
Luke
On Dec 6, 2007 7:
Hi,
If I have something like
data Patootie = Pa Int | Tootie Int
and I want to pull out the indices of all elements of a list
that have type constructor Tootie, how would I do that?
I thought I might be able to use findIndices, but I don't
know how to express the predicate.
_
Hi!
I am new to Haskell, but I have background in various programming
languages (including Lisp)
I have very basic question, if there is a way to match algebraic types
constructors besides
use of pattern matching. I wrote today code like this:
data Flag = Verbose |
Input String |
tootieIndices = findIndices isTootie
where isTootie (Pa _) = False
isTootie (Tootie _) = True
would be my first approach.
/g
On 2/10/06, Creighton Hogg <[EMAIL PROTECTED]> wrote:
> Hi,
> If I have something like
> data Patootie = Pa Int | Tootie Int
> and I want to pull out th
On Fri, 10 Feb 2006, Creighton Hogg wrote:
> Hi,
> If I have something like
> data Patootie = Pa Int | Tootie Int
> and I want to pull out the indices of all elements of a list
> that have type constructor Tootie, how would I do that?
>
> I thought I might be able to use findIndices, but I don't
Or inline as
> findIndices (\x -> case x of Tootie _ -> True; _ -> False) listOfPasAndTooties
There was a recent thread about wanting a more succint way to write
this (unary pattern matching):
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/11109
If John got his wish, then you could write s
Creighton Hogg <[EMAIL PROTECTED]> writes:
> data Patootie = Pa Int | Tootie Int
> and I want to pull out the indices of all elements of a list
> that have type constructor Tootie, how would I do that?
x = [Pa 3, Tootie 5, Pa 7, Tootie 9, Pa 11]
y = [ i |Tootie i <- x ]
z = [ i | i@(Tootie
On 10/02/06, Creighton Hogg <[EMAIL PROTECTED]> wrote:
> Hi,
> If I have something like
> data Patootie = Pa Int | Tootie Int
> and I want to pull out the indices of all elements of a list
> that have type constructor Tootie, how would I do that?
>
> I thought I might be able to use findIndices, bu
On Fri, 5 Mar 2004, Vadim Zaliva wrote:
> Hi!
>
> I am new to Haskell, but I have background in various programming
> languages (including Lisp)
>
> I have very basic question, if there is a way to match algebraic types
> constructors besides
> use of pattern matching. I wrote today code like th
On Mar 5, 2004, at 12:41, Brandon Michael Moore wrote:
At the lower level of remimplementing your functions I can suggest a
few
things.
Brandon,
Thanks for great suggestions! Following them, here is how I redone the
code:
...
import Data.Maybe
import Data.Either
import Data.Typeable
...
data
On Mar 5, 2004, at 15:48, Vadim Zaliva wrote:
OK, I figured it out. For sake of other novices like me here is what
you need
to do to make it work.
0. Need to import Data.Generics
1. Compile with '-fglasgow-exts' flag
2. When deriving from Data you also need to derive from Typeable.
It slightly b
Vadim Zaliva wrote:
[...] It slightly bothers me that this solution seems to be using non-standard
GHC extensions.
Hmmm, using generics seems like massive overkill for option handling. Could you
describe what you are exactly trying to achieve?
Cheers,
S.
On Mar 8, 2004, at 11:17, Sven Panne wrote:
Hmmm, using generics seems like massive overkill for option handling.
Could you
describe what you are exactly trying to achieve?
I am doing command line options parsing. I've defined Flag type with
constructor
for each possible option:
data Flag = Ver
On Mon, 8 Mar 2004, Vadim Zaliva wrote:
> I am doing command line options parsing. I've defined Flag type with
> constructor
> for each possible option:
>
> data Flag = Verbose |
> Input String |
> Output String |
> Filter String
> deriving (S
On Mar 8, 2004, at 12:55, Ben Rudiak-Gould wrote:
This would work, but I will have to write [] part for each option.
Generics approach is overkill but looks much neater when used.
But thanks for suggestion anyway, it is always good to learn yet
another way of doing things.
Sincerely,
Vadim
Try thi
How about this approach ?
I think this is a conventional and clear way,
though Flag Verbose has a verbose String.
-
import Data.List
import Data.Maybe
data Flag = Flag FlagType String
deriving Show
getFlagType (Flag ft _) = ft
data FlagType = Verbose | Input | Output | Filter
derivi
Hi,
I wish to align or match some Haskell types in order to represent a set
of ontologies and their embedded concpts [1]. I am not sure wheather
modules or classes could be used. I have done this task in a language
called Maude[2]. The code is below. I appreciate that Maude is not very
popular so
19 matches
Mail list logo