Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

haskell help

Name: Anonymous 2008-10-30 10:16

How do you create/operate on a two-dimensional array (or an equivalent structure) in Haskell? Any links?

THANKS!!

Name: Anonymous 2008-10-30 10:18

Haskell does not support two-dimensional arrays.

Name: Anonymous 2008-10-30 10:19

>>2
Ok but how do i define a class in C?

Name: Anonymous 2008-10-30 10:25

>>3
struct class_t { int var; };
struct class_t* class_new() { return malloc(sizeof(struct class_t); }
int class_var(struct class_t* self) { return self->var; };

Name: Anonymous 2008-10-30 10:35

>>2
What.


So how do I store, say, n by n table?

Name: Anonymous 2008-10-30 10:51

>>5
Sorry, Haskell can only do factorials, Fibonacci numbers and comonadic type transformers.

Name: Anonymous 2008-10-30 11:20

Prelude Array> listArray ((1,1),(2,3)) [5..]
array ((1,1),(2,3)) [((1,1),5),((1,2),6),((1,3),7),((2,1),8),((2,2),9),((2,3),10)]

Name: Anonymous 2008-10-30 11:26

import Data.Array

Name: Anonymous 2008-10-30 11:53

Haskell stole import from Python.

Name: Anonymous 2008-10-30 12:12

>>9
Did not!

Name: Anonymous 2008-10-30 12:20

>>10
Fuck off, Peyote-Joints.

Name: Anonymous 2008-10-30 12:23

>>9
Haskell merely imported import from Python

Name: Anonymous 2008-10-30 17:31

>>6
fact x = product [1..x]

Name: Anonymous 2008-10-30 17:50

>>13
WHAT IF X IS NEGATIVE
WHAT IF X IS ZERO
YOUR FACTORIAL FUNCTION IS INCORRECT
PLEASE FIX IT
ARSEHOLE

Name: Anonymous 2008-10-30 18:17

>>14
Hugs> product [1..20]
2432902008176640000
Hugs> product [1..(-1)]
1
Hugs> product [1..0]
1

Name: Anonymous 2008-10-30 18:19

ghc is the standard

Name: Anonymous 2008-10-30 18:20

>>14
WHAT IF X IS NEGATIVE
Then you supplied an invalid argument. It's like asking ``WHAT IF X IS A STRING''. (Note: Haskell' may add natural numbers as a type, which will catch these errors for you1)
WHAT IF X IS ZERO
Then [1..x] will result in [] and the correct answer will be returned.

1 http://hackage.haskell.org/trac/haskell-prime/wiki/Natural

Name: Anonymous 2008-10-30 20:30

#include <math.h>
double fact(double n){
  return tgamma(n);
}


C > Haskell

Name: Anonymous 2008-10-30 20:30

#include <math.h>
double fact(double n){
  return tgamma(n + 1);
}


C > Haskell

Name: Anonymous 2008-10-30 22:17

given g i j make a 2D array..

array (1,n) [ (i,(f i)) | i <- [1..n]] where
  f i = array (1,m) [(g i j) | j <- [1..m]]

Name: Anonymous 2011-02-03 8:22

Name: Anonymous 2011-02-18 13:45

<-- check 'em dubz

Name: Anonymous 2013-01-18 22:25

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

Don't change these.
Name: Email:
Entire Thread Thread List