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

Pages: 1-

[Haskell] Help

Name: Anonymous 2013-07-15 3:49

I need to write the function that has the P -> P type where the type P means prime numbers. There is the question: how to define P in haskell?

Name: Anonymous 2013-07-15 3:57


isPrime :: Num a => a -> Bool
...

function :: Num a => a -> a
function n
    | not $ isPrime n = error "not a prime"
    | otherwise       = ...

Name: Anonymous 2013-07-15 4:15


(defun (fun x)
  (assert (primep x))
  (let ((ret ...))
    (assert (primep ret))
    ret))

Name: P must be a type 2013-07-15 4:36

>>2
Congratulations! You are an idiot!

Name: Anonymous 2013-07-15 4:55

>>4
what's your problem? bump, to counter your angry sage.

Name: Anonymous 2013-07-15 4:58

Shohet sounds a lot like shoggoth

Name: Anonymous 2013-07-15 5:32

>>5
Okay. sorry. You're a reasonable person and very helpful. Indeed, P can also be a predicate. Why didn't I think of that myself?

Name: Anonymous 2013-07-15 5:33

>>6
It literally means "the one who slaughters", and has this meaning of a servant doing unclean work (slaughter), so yeah, Lovecraft knew his business.

Name: Anonymous 2013-07-15 5:37

>>7
If you want P to be a type, use a different language that has dependent types.

Name: Anonymous 2013-07-15 5:59

>>9
>use a different language that has dependent types
Which, for example? And please show how to define the type P in such language.

Name: Anonymous 2013-07-15 6:17

>>10

See https://en.wikipedia.org/wiki/Dependent_types#Comparison

But note. You are going down a road where you will never be able to use any of this knowledge professionally outside of academia.

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