Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Feb 2010

    Question Haskell Matrix Question NEED HELP!

    hi I have a question about haskell coding.


    One of many ways to define matrices in Haskell is the list of matrix rows, where a row is a list of double precision oating point numbers:

    type Matrix=[[Double]]
    Using this type you should define the following functions (definition of dim is given as an inspirational example).

    dim :: Matrix -> (Int,Int) --returns matrix dimension (number of rows and columns)
    dim m = if (not.isMatrix) m then error "Not a matrix" else (length m, length (head m))

    isMatrix :: Matrix -> Bool --checks whether all rows have the same length
    isMatrix m = and [length (head m) == length a | a <- m]
    I have done upto here and I am stuck on multSM.

    multSM :: Double -> Matrix -> Matrix --multiplies a scalar and a matrix
    when I do:

    multSM d m = [[(b*a)| b<-[d], a<-(head m)]] or [map (*d) (head m)]
    ...I get (using Hugs):

    Main> multSM 3 [[2,3,4],[1,3,4],[6,3,0]]
    So I solve 3 [2,3,4] but I do not know how to get the rest 3 [[1,3,4],[6,3,0].

    Please help me on this problem.

    These are rest of unsolved questions if anyone can help with:
    Last edited by inkwang; February 3rd, 2010 at 03:21 AM.

Similar Threads

  1. Yahoo email account comprimised by secret question
    By dolemite in forum Web Security
    Replies: 8
    Last Post: June 14th, 2004, 11:14 PM
  2. Question Time
    By jm459 in forum Tech Humor
    Replies: 1
    Last Post: April 14th, 2004, 01:41 PM
  3. Maximum performance question
    By Fasheezy in forum Hardware
    Replies: 5
    Last Post: February 5th, 2004, 03:25 PM
  4. Test Your General Linux Knowledge
    By smirc in forum AntiOnline's General Chit Chat
    Replies: 6
    Last Post: May 13th, 2002, 04:35 PM
  5. Test Your Knowledge of Redhat?
    By smirc in forum AntiOnline's General Chit Chat
    Replies: 3
    Last Post: May 13th, 2002, 03:24 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.