This file contains 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
;;; mell.el --- MELL Emacs Lisp Library | |
;; | |
;; AUTHOR: Hiroyuki Komatsu <[email protected]> | |
;; LICENCE: GPL2 | |
;; $Id: mell.el,v 1.4 2003/03/18 03:34:45 komatsu Exp $ | |
;; Version: 1.4.0 | |
;; | |
;; ------------------------------------------------------------ | |
;; XEmacs と FSF Emacs の差異を吸収 |
This file contains 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 tnoda.pe10) | |
(defn- sieve | |
"Returns an array of primes below len. Retrieved from | |
https://github.com/tnoda/tnoda.math.prime." | |
[^long len] | |
(let [n len | |
not-prime (doto (boolean-array n) | |
(aset 0 true) | |
(aset 1 true)) |
This file contains 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
class UnionFind: | |
"""Weighted quick-union with path compression. | |
The original Java implementation is introduced at | |
https://www.cs.princeton.edu/~rs/AlgsDS07/01UnionFind.pdf | |
>>> uf = UnionFind(10) | |
>>> for (p, q) in [(3, 4), (4, 9), (8, 0), (2, 3), (5, 6), (5, 9), | |
... (7, 3), (4, 8), (6, 1)]: | |
... uf.union(p, q) |
This file contains 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
import scala.annotation.tailrec | |
object BinarySearch { | |
def lowerBound(xs: Array[Int], x: Int): Int = { | |
@tailrec | |
def loop(first: Int, count: Int): Int = | |
if (count == 0) first | |
else { | |
val step = count / 2 | |
if (xs(first + step) < x) loop(first + step + 1, count - step - 1) |
This file contains 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
(let [m (BattleMap. "Ironbottom Sound") | |
f (Fleet. "Center Fleet")] | |
(loop [] | |
(doto f .repair .supply) | |
(when (and (.isFullyRepaired f) | |
(.isFullySupplied f) | |
(>= (.morale f) 40)) | |
(.attack f m) | |
(if (-> m .gauges pos?) | |
(recur)))) |
This file contains 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
(defun shibayu36/chomp (str) | |
(replace-regexp-in-string "[\n\r]+$" "" str)) | |
(defun anything-git-project-project-dir () | |
(shibayu36/chomp | |
(shell-command-to-string "git rev-parse --show-toplevel"))) | |
(defun anything-c-sources-git-project-for () | |
(loop for elt in | |
'(("Modified files (%s)" . "--modified") |
This file contains 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
package recfun | |
object DrillOne { | |
// sum of arithmetic progression | |
def soap(x: Int): Int = | |
if (x == 0) 0 | |
else soap(x - 1) + x | |
// factorial | |
def fact(x: Int): Int = |
This file contains 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
require 'rake' | |
require 'rspec/core/rake_task' | |
RSpec::Core::RakeTask.new(:spec) | |
task :default => :spec |
This file contains 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
public class HelloWorld { | |
public static void helloWorld() { | |
System.out.println("Hello, world!"); | |
} | |
} |