A collection of a bunch of interesting PL links and papers.**
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user=> (def ! #(reduce * (take % (iterate inc 1)))) | |
| #'user/! | |
| user=> (! 5) | |
| 120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user=> (defn prime? [x] | |
| #_=> (empty? (filter #(= 0 (rem x %)) (range 2 (inc (int (Math/sqrt x))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {- | |
| FirstScript.hs | |
| Akhilesh . S | |
| -} | |
| -- The Value size is an integer (Int), defined to be | |
| -- the sum of twelve and thirteen. | |
| fac :: Int -> Int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |