Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am sefufuller on github.
  • I am sefu (https://keybase.io/sefu) on keybase.
  • I have a public key whose fingerprint is 5054 184E 42ED 3231 ECB5 4A4A B7DF 76AD 5A3F B9EA

To claim this, I am signing this object:

@sefufuller
sefufuller / AreaTriangle.hs
Last active August 29, 2015 14:18
AreaTriangle
areaTriangleTrig a b c = c * height / 2 -- use trigonometry
where
cosa = (b ^ 2 + c ^ 2 - a ^ 2) / (2 * b * c)
sina = sqrt (1 - cosa ^ 2)
height = b * sina
areaTriangleHeron a b c = result -- use Heron's formula
where
result = sqrt (s * (s - a) * (s - b) * (s - c))
s = (a + b + c) / 2
@sefufuller
sefufuller / Fibonacci.hs
Last active August 29, 2015 14:18
Fibonacci numbers
-- Type annotation (optional)
fib :: Int -> Integer
-- With self-referencing data
fib n = fibs !! n
where fibs = 0 : scanl (+) 1 fibs
-- 0,1,1,2,3,5,...
-- Same, coded directly
fib n = fibs !! n
@sefufuller
sefufuller / sine.sc
Last active August 29, 2015 14:17
SuperCollider’s expressive power. It modulates the pitch of a single sine-wave oscillator.
play{SinOsc.ar(OnePole.ar(Mix(
LFSaw.ar([1,0.99],[0,0.6],2000,2000).trunc([400,600])*[1,-1]
),0.98)).dup*0.1}