Skip to content

Instantly share code, notes, and snippets.

Vesa Marttila ponzao

Block or report user

Report or block ponzao

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ponzao / vice.clj
Created Sep 26, 2016
Clojure Spec coercion nonsense
View vice.clj
(ns vice
(:require [clojure.spec :as s]
[clj-time.core :as t]
[clj-time.format :as tf])
(:import [org.joda.time DateMidnight DateTime]
[java.util UUID]
[clojure.lang Keyword]
[java.math BigInteger]
[java.util.regex Pattern]))
View vimrc
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()
Plugin 'gmarik/Vundle.vim'
Bundle 'tpope/vim-classpath'
Bundle 'tpope/vim-leiningen'
Bundle 'tpope/vim-projectionist'
View deep_merge_with_key.clj
(defn merge-with-key
[f & maps]
(when (some identity maps)
(reduce (fn [acc x]
(reduce (fn [m [k v]]
(if (contains? m k)
(assoc m k (f k (get m k) v))
(assoc m k v)))
View output.clj
(["Marcus" 17]
["Baba" 16]
["Sami" 14]
["Tuomas" 14]
["Kabu" 14]
["Jesse" 11]
["Lydä" 9]
["Jonde" 9]
["Jebu" 9]
View count_vowels.clj
(def vowels
#{\a \e \i \o \u})
(defn count-vowels
(count (keep vowels (.toLowerCase s))))
View 4clojure_178.clj
(fn best-hand
(let [ranks (map second hand)
suits (map first hand)
rank-freqs (sort (vals (frequencies ranks)))]
(letfn [(flush? [hand]
(apply = suits))
(straight? [hand]
(let [straight-hands (set (map set (partition 5 1 [\A \2 \3 \4 \5
\6 \7 \8 \9 \T
View positions.fs
let positions x (arr: 'a []) =
let n = arr.Length - 1
let idxs = [|0..n|] idxs arr
|> Array.filter (fun (_, v) -> v = x)
|> (fun (idx, _) -> idx)
positions 'b' [|'a';'b';'a';'a';'b'|]
// [|1; 4|]
View sudoku.clj
(ns sudoku
(:require [clojure.set :as set]))
(defn row-values
[board [row _]]
(set (get board row)))
(defn- transpose
(vec (apply map vector matrix)))
View map_matrix.clj
(defn map-matrix
[f colls]
(vec (map-indexed (fn [y row]
(vec (map-indexed (fn [x value]
(f value x y))
ponzao / tictactoe.clj
Last active Dec 22, 2015
Declarative (= bloated) Tic-Tac-Toe solver in Clojure and core.logic.
View tictactoe.clj
(defn solve
(remove nil?
(run* [q]
(macro/symbol-macrolet [_ (lvar)]
(== q grid)
((== grid [[q _ _]
[_ q _]
[_ _ q]]))
You can’t perform that action at this time.