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

Pages: 1-

Bitches don't know about my Erlang

Name: Anonymous 2008-01-13 22:00

-module(mathStuff).
-export([factorial/1, area/1]).

factorial(0) -> 1;
factorial(N) -> N * factorial(N-1).

    area({square, Side}) ->
        Side * Side;
    area({circle, Radius}) ->
        3 * Radius * Radius;
    area({triangle, A, B, C}) ->
        S = (A + B + C)/2,
        math:sqrt(S*(S-A)*(S-B)*(S-C));
    area(Other) ->
        {invalid_object, Other}.

Name: Anonymous 2008-01-13 22:04

>>1
At least bitches aren't as ugly as your syntax.

Name: Anonymous 2008-01-13 22:19

Would this by any chance be one of those inferior, Θ(n) in memory usage versions of factorial?

Name: Anonymous 2008-01-13 22:33

wow, if erlang makes you want to approximate PI to 3, then it truely  is a great language... wait, no, i mean stupid

Name: Anonymous 2008-01-13 23:57

>>4
if you wanted a cheap way to approximate pi, 355/113 provides a pretty good solution.

Name: Anonymous 2008-01-14 0:02

PI = 24/7
No exceptions

Name: Anonymous 2008-01-14 0:08

>>5
If you wanted a cheap way to approximate π, a hardcoded constant double provides a pretty good solution.

Name: Anonymous 2008-01-14 0:14

>>7
fldpi

Name: Anonymous 2008-01-14 0:38

>>7
What if you need an integer approximation?

Name: Anonymous 2008-01-14 0:44

>>9
What the hell is an integer approximation? Here's an integer for you: 3

Name: Anonymous 2008-01-14 0:49

>>10
An approximation which is an integer. You need to upgrade your English compiler or something.

Name: Anonymous 2008-01-14 2:04

>>11
Have you read SICP?

Name: Anonymous 2008-01-14 2:14

>>12
Is that even relevant to the discussion, or is it just your way of asking whether I have read SICP?

Name: Anonymous 2008-01-14 4:54

A nice approximation of pi is:
3.14159265358979324

It's what I use since I memorized it.

Name: Anonymous 2008-01-14 4:58

>>14
Your seventh decimal place is incorrect. FAIL.

Name: Anonymous 2008-01-14 5:18

>>9
Then use pi(n)/10n, where n is the number of decimal digits of π that you want to use, and the function pi returns 10nπ rounded to the nearest integer.

e.g. if you need π to 3 decimal places, use 3141/10000, and evaluate in such a way that the division by 10000 is calculated last.

Name: Anonymous 2008-01-14 5:37

>>1
>factorial

:face fucking palm:

Name: Anonymous 2008-01-14 6:31

>>1
So you just wanted to show us that you can do the very first tutorial exercises poorly?

Name: Anonymous 2008-01-14 11:22

>>15
lrn2facts
The only thing wrong with >>14 is that the next decimal is 6, so his number rounded incorrectly.

Name: Anonymous 2008-01-14 12:01

3.14159265358979 is all I know.

Name: Anonymous 2008-01-14 13:11

Sine, cosine, cosine, sine, three-point-one-four-one-five-nine!

Name: Anonymous 2008-01-14 21:54

Shift to the left, shift to the right, push down, pop up, byte byte byte!

Name: Anonymous 2009-03-18 3:46

I feel the need, the need for weed!

Marijuana MUST be legalized.

Name: Anonymous 2010-11-02 9:55

Name: Anonymous 2010-12-21 2:45

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