Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
| function Epley(wt, reps) { | |
| return wt * ( 1 + reps / 30); | |
| } | |
| function Brzycki(wt, reps) { | |
| return wt * 36 / (37 -reps); | |
| } | |
| function Lander(wt, reps) { | |
| return 100 * wt / (101.3 - reps * 2.67123); |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
| (defn summarize | |
| "Summarizes a data set. Groups data by result of groupingf applied to each | |
| member of coll. Applies summarizingf to each group." | |
| [groupingf summarizingf coll] | |
| (let [grouped (group-by groupingf coll)] | |
| (map #(list (first %) (summarizingf (second %))) grouped))) | |
| (defn summarize-count | |
| [groupingf coll] | |
| (summarize groupingf count coll)) |
| require 'net/https' | |
| require 'uri' | |
| # create a path to the file "C:\RailsInstaller\cacert.pem" | |
| cacert_file = File.join(%w{c: RailsInstaller cacert.pem}) | |
| uri = URI.parse("https://curl.haxx.se/ca/cacert.pem") | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| http.use_ssl = true | |
| http.verify_mode = OpenSSL::SSL::VERIFY_NONE |
| using System.ComponentModel; | |
| using System.Collections.Generic; | |
| using System.Threading; | |
| using System; | |
| namespace Ecounysis.DataProcessing | |
| { | |
| // How to use this: | |
| // 1. create a subclass |
| open System | |
| let printLines n = | |
| for s = 1 to n do | |
| Console.WriteLine() | |
| n | |
| let getInt x = | |
| let succ = Int32.TryParse(x) |
| module Parsing = | |
| //type Char = string | |
| //type Str = string | |
| type Remaining = string | |
| type Result<'a> = Success of 'a * Remaining | |
| | Failure | |
| type Parser<'a> = string -> Result<'a> | |
| let divisors x = | |
| List.init (int (Math.Sqrt(float x))) (fun x -> x + 1) | |
| |> List.filter (fun y -> x % y = 0) | |
| |> List.map (fun y -> [y ; x / y]) | |
| |> List.reduce (fun x y -> x @ y) | |
| |> List.sort | |
| let isPrime x = | |
| List.length (divisors x) = 2 |
| namespace Obfuscation | |
| // very weak encryption | |
| // uses a "one-time pad" that is used over and over | |
| // http://en.wikipedia.org/wiki/One-time_pad | |
| module Text = | |
| type Operation = | |
| | Encryption |