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
;;Code for https://www.jinshuju.net/f/EGQL3D | |
(defn- read-n-numbers [n] | |
(repeatedly n #(let [x (read-line)] | |
(Integer/valueOf x)))) | |
(defn- say-what [inputs words n] | |
(let [[x y z] inputs | |
rs (filter #(zero? (rem n %)) inputs)] | |
(cond | |
;;rule 5 |
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
/* ******************************************* | |
// LICENSE INFORMATION | |
// The code, "Detecting Smartphones Using PHP" | |
// by Anthony Hand, is licensed under a Creative Commons | |
// Attribution 3.0 United States License. | |
// | |
// Updated 01 March 2010 by Bryan J Swift | |
// - Remove un-needed if statements instead just returning the boolean | |
// inside the if clause | |
// |
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
/* ******************************************* | |
// LICENSE INFORMATION | |
// The code, "Detecting Smartphones Using PHP" | |
// by Anthony Hand, is licensed under a Creative Commons | |
// Attribution 3.0 United States License. | |
// | |
// Updated 01 March 2010 by Bryan J Swift | |
// - Remove un-needed if statements instead just returning the boolean | |
// inside the if clause | |
// |
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
/** | |
* Throw even checked exceptions without being required | |
* to declare them or catch them. Suggested idiom: | |
* <p> | |
* <code>throw sneakyThrow( some exception );</code> | |
*/ | |
static public RuntimeException sneakyThrow(Throwable t) { | |
// http://www.mail-archive.com/javaposse@googlegroups.com/msg05984.html | |
if (t == null) | |
throw new NullPointerException(); |
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
;;; This was installed by package-install.el. | |
;;; This provides support for the package system and | |
;;; interfacing with ELPA, the package archive. | |
;;; Move this code earlier if you want to reference | |
;;; packages in your .emacs. | |
(add-to-list 'load-path "~/.emacs.d/marmalade") | |
(require 'package) | |
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) | |
(package-initialize) | |
';;使用缩写模式 |
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 joy.q) | |
;; nil | |
(defn nom [n] (take n (repeatedly #(rand-int n)))) | |
;; #'joy.q/nom | |
(defn sort-parts [work] | |
(lazy-seq | |
(loop [[part & parts] work] ;; Pull apart work - note: work will be a list of lists. | |
(if-let [[pivot & xs] (seq part)] ;; This blows up unless work was a list of lists. |
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 monads | |
(:require clojure.set)) | |
(declare ^:dynamic return | |
^:dynamic bind) | |
(defn lift-inc [v] | |
(return (inc v))) | |
(defn m-add [mv n] |
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
defmodule CounterSupervisor do | |
use Supervisor | |
def start_link(v \\ 0) do | |
Supervisor.start_link(__MODULE__, v) | |
end | |
@counter_name Counter | |
#supervisor callback | |
def init(v) do |
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
defmodule MyUnless do | |
defmacro unless(clause, then_clause, else_clause \\ nil) do | |
quote do | |
if !unquote(clause) do | |
unquote(then_clause) | |
else | |
unquote(else_clause) | |
end | |
end | |
end |
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
defmodule MySigils do | |
def sigil_i(string, []), do: String.to_integer(string) | |
def sigil_i(string, [?n]), do: -String.to_integer(string) | |
end |
OlderNewer