「そもそも概念が分からない」という方に向けた説明です.
簡略化のため大幅に説明を省略しています. ご容赦ください.
誤りは御指摘いただければ幸いです.
「ファンクタ」, 「アプリカティブ」, 「モナド」 などは Haskell に限定された概念・用語ではありませんが,
(require '[clojure.test :refer (with-test are run-tests)]) | |
(with-test | |
(defn awtp [cs a] | |
((fn f [[h & r] a] | |
(cond | |
(zero? a) #{{}} | |
(nil? h) #{} | |
:else (set | |
(mapcat (fn [c] |
(require '[clojure.test :refer (with-test are run-tests)]) | |
(with-test | |
(defn str-drop-while-same [& args] | |
(if (some nil? args) args | |
(->> (map #(concat % (repeat nil)) args) | |
(apply map vector) | |
(drop-while #(apply = %)) | |
(take-while #(some identity %)) | |
(apply map str)))) |
;;; Copyright (c) 2013 Yoshinori Kohyama. Distributed under the BSD 3-Clause License. | |
(ns puyo | |
(:require [clojure.test :refer (with-test run-tests are)] | |
[clojure.set :refer (union)] | |
[clojure.string :as string])) | |
(with-test | |
(defn- fall-one [b s] | |
(->> (reverse b) | |
(apply map vector) |
#include <stdio.h> | |
#include <stdlib.h> | |
#define u16 unsigned short | |
#define u8 unsigned char | |
static u16 | |
crc16(u8 *p, int n) | |
{ | |
static const u16 wCRCTable[] = { |
(require '[clojure.test :refer (is)]) | |
(require '[clojure.string :as s]) | |
(def input " | |
75 | |
95 64 | |
17 47 82 | |
18 35 87 10 | |
20 04 82 47 65 | |
19 01 23 75 03 34 |
;; 閏年かどうか | |
(defn leap? [year] | |
(and (zero? (mod year 4)) | |
(or (pos? (mod year 100)) | |
(zero? (mod year 400))))) | |
;; 西暦で与えられた年の各月の日数のリスト | |
(defn numbers-of-days [year] | |
(if (leap? year) | |
;;Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec |
(require '[clojure.string :as s]) | |
(require '[clojure.test :refer (deftest run-tests is)]) | |
(defn trans [[& rows]] (apply (partial map list) rows)) | |
(defn flip [mat] (map reverse mat)) | |
(defn rot45 [mat] | |
(let [w (count (first mat)) | |
h (count mat) |
(require '[clojure.test :refer (is)]) | |
(defn pms | |
"Permutations lexicographic by index." | |
[[a & [b & [c & _]] :as ls]] | |
(cond | |
(nil? a) '() | |
(nil? b) `(~a) | |
(nil? c) `((~a ~b) (~b ~a)) | |
:else (mapcat (fn [h] (map (fn [r] (cons h r)) |
(require '[clojure.test :refer (is)]) | |
(defn in-words | |
"Represents the given number in English words without spaces nor hyphens. | |
This works with a number in the range from 1 to 1000" | |
[n] | |
(cond | |
(< n 20) | |
(["" "one" "two" "three" "four" "five" "six" "seven" "eight" | |
"nine" "ten" "eleven" "twelve" "thirteen" "fourteen" |