modify a haskell program.

This is a discussion on modify a haskell program. within the Tech Board forums, part of the Community Boards category; i want to have this code but without n there. n is a number that first is one and everytime ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    230

    modify a haskell program.

    i want to have this code but without n there. n is a number that first is one and everytime it must increase per one. how can i do this ? thanks...

    Code:
    f :: Integer -> Integer -> Integer -> Integer -> Integer
    f n k d u 
               | k<0
               	= error "negative argument 1"
               | d<0
                    = error "negative argument 2"
               | u<0
                    = error "negative argument 3"
               | n^k + d^n >= u
                    = n
               | otherwise
                    = m where m = f (n+1) k d u

  2. #2
    Registered User
    Join Date
    Aug 2010
    Posts
    230
    also can anyone find this error ?
    ERROR "homehaskelllab2.hs":15 - Syntax error in input (unexpected `|')


    Code:
    {- ASKISI 3 -}
    
    lg :: Integer -> Integer
    lg n
             | (n>=0) && (n<=1)
                  = 1
             | otherwise
                  = lg (abs( n `div` 2)) + 1
                  
                  
    e :: Integer -> Integer -> Integer
    e a b = e (w-1) 
      where w = ehlp :: Integer ->Integer -> Integer
                ehlp a b 
                         | lg a > lg b
                             = lg a where lg :: Integer -> Integer
                                          lg n
                                                | (n>=0) && (n<=1)
                                                    = 1
                                                | otherwise
                                                    = lg (abs( n `div` 2)) + 1
                         | otherwise
                             = lg b

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Homework Help, simple program, unsure newbie :(
    By Aslan14 in forum C Programming
    Replies: 13
    Last Post: 11-14-2010, 04:07 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 06:49 PM
  5. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 07:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21