This file contains hidden or 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 clojure4.core) | |
;;; Re-implement Clojure "comp" for 4Clojure problem #58 (as "komp") | |
(defn komp | |
([] (fn [n] (identity n))) | |
([fn1] (fn [& n] (apply fn1 n)) ) | |
([fn1 fn2] (fn [& n] | |
(fn1 ((fn [m] (apply fn2 m)) n)))) | |
([fn1 fn2 & fns] (fn [& n] | |
(fn1 ((fn [m] (apply (apply komp (conj fns fn2)) m )) n ))))) |
This file contains hidden or 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
(defn tipe [s] | |
(let [sym1 (gensym) sym2 (gensym) | |
sym3 (gensym) s12 (conj s {sym1 sym2}) | |
s1221 (conj (conj s {sym2 sym1}) s12)] | |
(if (get s12 sym1) :map | |
(if (get s12 {sym1 sym2}) :set | |
(if (= (first s1221) s12) :list :vector))))) | |
(= :map (tipe {:a 1, :b 2})) | |
(= :list (tipe (range (rand-int 20)))) |
This file contains hidden or 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
(defn rducts | |
([f aseq] (lazy-seq (rducts f (f (first aseq)) (rest aseq)))) | |
([f accum aseq] | |
(lazy-seq (cons accum (let [fs (first aseq) rs (rest aseq)] | |
(if (not (seq rs)) | |
(list (f accum fs)) | |
(rducts f (f accum fs) rs))))))) | |
(take 5 (rducts + (range))) | |
(rducts conj [1] [2 3 4]) |
This file contains hidden or 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
;; My solution | |
(defn intervs [s] | |
(let [sorted (sort (into #{} s)) | |
fs (first sorted)] | |
(cond (not (seq sorted)) () | |
(= 1 (count sorted)) (list [fs fs]) | |
(not= (inc fs) (second sorted)) (cons [fs fs] (intervs (rest sorted))) | |
:ELSE | |
(let [pairs (partition 2 1 sorted)] | |
(let [contig (take-while #(= (inc (first %)) (second %)) pairs) |
This file contains hidden or 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
open System | |
open System.IO | |
open System.Collections.Generic | |
open System.Text | |
open System.Text.RegularExpressions | |
#load "Library1.fs" | |
open Library1 | |
// Define your library scripting code here |
This file contains hidden or 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
// Dr. Syme meets Dr. Seuss :slightly_smiling_face: | |
// Expert FSharp 4.0 p. 165 read aloud: | |
module public GlobalClock = | |
type TickTock = Tick | Tock | |
let mutable private clock = Tick | |
let private tick = new Event<TickTock>() | |
let internal oneTick() = | |
(clock <- match clock with | |
Tick -> Tock | |
| Tock -> Tick) |
This file contains hidden or 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
// OpenXML-test-errors OXML-1 | |
open System.IO | |
open System.IO.Packaging | |
open DocumentFormat.OpenXml.Packaging | |
open DocumentFormat.OpenXml.Wordprocessing | |
[<EntryPoint>] | |
let Main args = | |
let byteArray = File.ReadAllBytes "Test.docx" | |
use mem = new MemoryStream() |
This file contains hidden or 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
open System | |
open System.Text.RegularExpressions | |
exception QuitProgram | |
(* // defining this function causes the initial "> " to not be displayed first | |
let ProcessInput = | |
let input = System.Console.ReadLine() | |
try | |
let f = System.Single.Parse(input) |
This file contains hidden or 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
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) } | |
# Two parameters | |
map { param($x, $y) $x + $y } @(1,2,3) 10 | |
# Anonymous function as a value | |
$squareIt = { param($x) $x + $x } | |
map $squareIt @(1,2,3) | |
# One parameter |
This file contains hidden or 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
1 subgoal | |
n, m, p : nat | |
H : leb n m = true | |
IHp : leb (p + n) (p + m) = true | |
______________________________________(1/1) | |
leb (S p + n) (S p + m) = true | |
(* How does assumption complete the goal? I agree it's true but don't see how Coq gets that. *) |
OlderNewer