Skip to content

Instantly share code, notes, and snippets.

View akhileshs's full-sized avatar

Akhilesh Srikanth akhileshs

  • San Francisco, CA
View GitHub Profile
user=> (def ! #(reduce * (take % (iterate inc 1))))
#'user/!
user=> (! 5)
120
>>> def prove(f):
... s = Solver()
... s.add(Not(f))
... if s.check() == unsat:
... print "proved"
... else:
... print "failed to prove"
>>> p, q = Bools('p q')
>>> demorgan = And(p, q) == Not(Or(Not(p), Not(q)))
>>> prove(demorgan)
user=> (defn prime? [x]
#_=> (empty? (filter #(= 0 (rem x %)) (range 2 (inc (int (Math/sqrt x)))))))
@akhileshs
akhileshs / trial1.hs
Created October 7, 2015 18:48
Haskell Trial
{-
FirstScript.hs
Akhilesh . S
-}
-- The Value size is an integer (Int), defined to be
-- the sum of twelve and thirteen.
fac :: Int -> Int
(ns fluokitty.core
(:use [uncomplicate.fluokitten core jvm]))
(map inc [1 2 3])
(fmap inc [1 2 3])
(fmap + [1 2 3] [1 2 3 4])
(fmap + [1 2 3] (list 1 2 3))
scala> trait T[+A] {
| def flatMap[B](f: A => T[B]): T[B] // bind operation
| def map[B](f: A => B): T[B]
| }
defined trait T
scala> trait Exp { def eval() : Int }
defined trait Exp
scala> trait Lit extends Exp {
| val x : Int
| def eval() = x
| }
defined trait Lit
scala> trait Add extends Exp {
scala> case class B[F, T](c: B[F, T] => (F => T)) extends (B[F, T] => (F => T)) {
| def apply(b: B[F, T]) = c(b);
| }
defined class B
scala> def Y[F, T] = (f: (F => T) => F => T) =>
| B[F, T](x => f(x(x)(_)))(B(x => f(x(x)(_))))
Y: [F, T]=> ((F => T) => (F => T)) => (F => T)
@akhileshs
akhileshs / springer-free-maths-books.md
Created December 28, 2015 13:08 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links