[Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Gjuro Chensen

Hello everyone! 

Im a Haskell newbie, and Ive have few unanswered questions. For someone more
experienced (at least I think so) its a very simple task, but I just cant
get a grip on it and its pretty frustrating. It wouldn't be that bad if I
haven't browse thru bunch of pages and tutorials and still nothing...
The problem is: take a string, and if every words starts with uppercase
letter then print yes, else no.
Forum Text Bold - yes
Frog image File - no

Ive had my share of approaches to this, but I just cant make it work. 
Standard one seemed the most simple:

search :: String - String
search [] = []


and then use words (splits string on space) to split the string so I could
get a list and go through it recursively. But how to apply words to entered
string in this form? 

To find the first letter I came up with: first = take 1 (head x). And
compare it with elem or ASCII values to determine if its upper case.

Any help, advice or suggestion is appreciated.

Thanks in advance!

-- 
View this message in context: 
http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24022673.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell - string to list isusses, and more

2009-06-14 Thread Gjuro Chensen



Gjuro Chensen wrote:
 
 
 /cut
 
 

I dont know everyone will see this, but I would like thank everyone who
found time to help, and not spam too much doing it:D. 
Well, I did it! Its not great (especially comparing to those one line
solutions, wow!), but it works.

module Main where

startsWithUpper :: String - Bool
startsWithUpper []= False
startsWithUpper string =
if myIsUpper(head(string)) then True 
else False

myIsUpper :: Char - Bool
myIsUpper x =
if x='A'  x = 'Z' then True 
else False

checkAll string = check (words string)

check :: [String] - Bool
check []=False
check x = 
if all startsWithUpper x then True
else False


Since importing modules isnt allowed, I made my own isUpper. And thats it,
for few days of Haskell, Im happy.

Once again, many many thanks to everyone!


-- 
View this message in context: 
http://www.nabble.com/Haskell---string-to-list-isusses%2C-and-more-tp24022673p24023759.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe