SunQuest
           Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old February 19th, 2007, 09:33 AM
Allan87 Allan87 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 14 Allan87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 13 m 42 sec
Reputation Power: 0
Haskell spaces

After running a test on this code I get;

Expected: Centre (5.5, 5.5), area 15.0
Actual: Centre (5.5,5.5), area 15.0

Which leaves me unaware of how to create a space between the coordinates. Any advice?

Code:
-- Display the combined area and centre of a list of shapes.

module Compound (combine) where

import Shape

-- Take a list of lines, convert into a list of shapes,
-- and then find and report the combined centre and area.

combine :: [String] -> String
combine input = "Centre " ++ show(finalCentroid(input)) ++ ", area " ++ show (totalArea(input))

-- Work out the total area of all shapes

totalArea :: [String] -> Double
totalArea[] = 0
totalArea (x:xs) = area (shape x) + totalArea xs

-- Work out the total of all x co-ordinates

centroidX :: [String] -> Double
centroidX [] = 0
centroidX (x:xs) = fst(centre (shape x)) + (centroidX xs)

-- Work out the total for all y co-ordinates

centroidY :: [String] -> Double
centroidY[] = 0
centroidY (x:xs) = snd(centre (shape x)) + centroidY xs

finalCentroid :: [String] -> Point
finalCentroid (x:xs) = ((centroidX (x:xs))/(totalArea (x:xs)), (centroidY (x:xs))/(totalArea (x:xs)))

Reply With Quote
  #2  
Old March 7th, 2007, 05:17 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 55 m 17 sec
Reputation Power: 17
Quote:
Any advice?

read any basic haskell tutorial. If you still have a problem with this, you're on the wrong course. If not, do your homework. If you still have questions post on a sensible place to ask questions about haskell, like comp.lang.haskell.

Reply With Quote
  #3  
Old March 8th, 2007, 06:09 AM
xnemesis64 xnemesis64 is offline
Google's No1 Supporter!
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2007
Location: irc.superirc.info
Posts: 569 xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level)xnemesis64 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 4 Days 15 h 48 m 12 sec
Reputation Power: 145
Send a message via MSN to xnemesis64 Send a message via Yahoo to xnemesis64 Send a message via Google Talk to xnemesis64 Send a message via Skype to xnemesis64
Always take a look at the official documentation for the language. Almost every language has one, and haskell is no exception. Take a look here. Or a simple google as suggested by jamieB will return numerous useful sites and resources such as this one.

Hope this helps
__________________
Did this post help? Please Click The Next To My Post
Need help? Did you try Google?
Take a look over at my current work in progress http://crispycrisp.org

Reply With Quote
  #4  
Old May 6th, 2007, 07:28 AM
safaa.khatib safaa.khatib is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 2 safaa.khatib User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 17 sec
Reputation Power: 0
Instance of mond

Hi all,
I hope here is the correct place where i can find the answer that i'm looking for.
I'm writing a code for the xxtea, it is a modification for the Tiny encryption algorithm. The problem is that when i am running my code it is giving me this:
"Instance of Monad (Array Word32) required for definition of coding"
the code is below; hope some one will reply and tell what is the problem.thnx


type TEA_arr = Array Word32 Word32

coding :: TEA_arr -> Word32 -> Word32 -> [Word32] -> Word32 -> Word32 -> TEA_arr
coding v s e k 0 _ = v
coding v s e k q p = do
let sum = getSum s
e = shiftSum sum
y = v ! (p+1)
z = v ! p
mx = getMx y z sum k e p
newarr = v // [(p,(v ! p)+ mx)]
coding newarr sum e k (q - 1) (p+1)

Reply With Quote
  #5  
Old May 16th, 2007, 11:24 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 592 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 1 h 55 m 17 sec
Reputation Power: 17
Quote:
Originally Posted by safaa.khatib
Hi all,
I hope here is the correct place where i can find the answer that i'm looking for.


Did you read the previous message? Take a look around you and see if other people are asking and solving questions like yours. Are they? No.

You could try haskell-cafe, but you might be unlikely to get much help until you read some basic tutorials and put in a bit of effort yourself.

Hint: do blocks are only used with monadic code, which yours is not.

Oh, and why hijack this thread then post your message again? With netiquette like that you might have to learn how to do your own homework. Bummer, eh?

Last edited by jamieB : May 16th, 2007 at 11:28 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > Haskell spaces


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway