Bitches don't know about my Erlang
1
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}.
2
Name:
Anonymous
2008-01-13 22:04
>>1
At least bitches aren't as ugly as your syntax.
3
Name:
Anonymous
2008-01-13 22:19
Would this by any chance be one of those inferior, Θ(n) in memory usage versions of factorial?
4
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
5
Name:
Anonymous
2008-01-13 23:57
>>4
if you wanted a cheap way to approximate pi, 355/113 provides a pretty good solution.
6
Name:
Anonymous
2008-01-14 0:02
PI = 24/7
No exceptions
7
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.
8
Name:
Anonymous
2008-01-14 0:14
9
Name:
Anonymous
2008-01-14 0:38
>>7
What if you need an integer approximation?
10
Name:
Anonymous
2008-01-14 0:44
>>9
What the hell is an integer approximation? Here's an integer for you:
3
11
Name:
Anonymous
2008-01-14 0:49
>>10
An approximation which is an integer. You need to upgrade your English compiler or something.
12
Name:
Anonymous
2008-01-14 2:04
13
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?
14
Name:
Anonymous
2008-01-14 4:54
A nice approximation of pi is:
3.14159265358979324
It's what I use since I memorized it.
15
Name:
Anonymous
2008-01-14 4:58
>>14
Your seventh decimal place is incorrect. FAIL.
16
Name:
Anonymous
2008-01-14 5:18
>>9
Then use pi(n)/10
n , where n is the number of decimal digits of π that you want to use, and the function pi returns 10
n π 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.
17
Name:
Anonymous
2008-01-14 5:37
>>1
>factorial
:face fucking palm:
18
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?
19
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.
20
Name:
Anonymous
2008-01-14 12:01
3.14159265358979 is all I know.
21
Name:
Anonymous
2008-01-14 13:11
Sine, cosine, cosine, sine, three-point-one-four-one-five-nine!
22
Name:
Anonymous
2008-01-14 21:54
Shift to the left, shift to the right, push down, pop up, byte byte byte!
23
Name:
Anonymous
2009-03-18 3:46
I feel the need, the need for weed!
Marijuana MUST be legalized.
24
Name:
Anonymous
2010-11-02 9:55