Skip to content

Instantly share code, notes, and snippets.

@kencoba
kencoba / palindrome-date-time.clj
Created March 10, 2011 05:57
output sequense of palindrome date-time
(comment
this code uses http://clojars.org/clj-time.)
(ns palindrome-date-time.core
(:require [clj-time.core :as t])
(:require [clj-time.format :as f]))
(def custom-formatter (f/formatter "yyyyMMdd"))
(defn date-seq [d]
@kencoba
kencoba / implies.clj
Created March 28, 2011 07:22
logical operator
(ns logic
(:use [clojure.test]))
(defmacro implies [p q] `(or (not ~p) ~q))
(deftest test-implies
(are [e p q] (= e (implies p q))
true true true
false true false
true false true
@kencoba
kencoba / sf_1.v
Created April 21, 2011 08:15
Software Foundations exercises
Inductive day : Type :=
| monday : day
| tuesday : day
| wednesday : day
| thursday : day
| friday : day
| saturday : day
| sunday : day.
Definition next_weekday (d:day) : day :=
@kencoba
kencoba / myLists.v
Created April 22, 2011 05:37
Software Foundations:Lists
Require Export Basics.
Module NatList.
Inductive natprod : Type :=
pair : nat -> nat -> natprod.
Definition fst (p:natprod):nat :=
match p with
| pair x y => x
@kencoba
kencoba / TWO.v
Created May 4, 2011 06:57
Category Theory. Proof of Two Object Category.
Require Export ConCaT.CATEGORY_THEORY.CATEGORY.Category.
Set Implicit Arguments.
Unset Strict Implicit.
Inductive Two_ob : Type :=
| obone : Two_ob
| obtwo : Two_ob.
Inductive Two_mor : Two_ob -> Two_ob -> Type :=
@kencoba
kencoba / Tutorial
Created May 6, 2011 05:46
tutorial.thy
theory ToyList
imports Datatype
begin
datatype 'a list = Nil ("[]")
| Cons 'a "'a list" (infixr "#" 65)
(* This is append function: *)
primrec app :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" (infixr "@" 65)
where
@kencoba
kencoba / credit-check-sum.clj
Created May 9, 2011 05:31
Check credit card number.
(defn- charlist-to-digits [lst]
(map #(Integer/parseInt %)
(map #(str (first %))
(partition 1 2 lst))))
(defn- odd-digits [card-num]
(charlist-to-digits (reverse card-num)))
(defn- even-digits [card-num]
(charlist-to-digits (rest (reverse card-num))))
@kencoba
kencoba / NaturalDeduction_p18.v
Created May 10, 2011 01:39
NaturalDeduction Dag Prawitz p18
Section NaturalDeduction_p18.
Variable D : Set.
Variable P : D -> D -> Prop.
Hypothesis Pxy : forall x, exists y, P x y.
Hypothesis PxyPyx : forall x y,(P x y) -> (P y x).
Lemma p18 : forall x, exists y, (P x y) /\ (P y x).
Proof.
intros x.
elim (Pxy x).
@kencoba
kencoba / projective_object.als
Created May 12, 2011 01:15
// P is projective object if there is some arrow f_bar such that e o f_bar = f.
open util/relation
sig P {
f : one X,
f_bar : one E
}
sig E {
e : one X
}
sig X {}
@kencoba
kencoba / casl.clj
Created May 19, 2011 06:19
CASL II Assembler
(ns casl-assembler
(:use [clojure.test :only (deftest is run-tests)]
[clojure.contrib.str-utils :only (re-split)]))
(def prog0
[
"PROG1 START GO"
"DATA1 DC 1"
"DATA2 DC 2"
"ANS DS 1"