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
| module semigroup | |
| export_type semigroup | |
| export concat | |
| {- Semigroup: anything with an associative operation | |
| Instead of a type class, we define a record type which specifies the | |
| necessary fields. |
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
| client = boto3.client("autoscaling") | |
| asg_paginator = client.paginator("describe_auto_scaling_groups") | |
| used_launch_configs = set([ | |
| asg["LaunchConfigurationName"] | |
| for page in asg_paginator.paginate() | |
| for asg in page["AutoScalingGroups"]]) | |
| # what if somebody makes a buch of AGS at this point in the execution? | |
| launch_config_paginator = client.paginator('describe_launch_configurations') |
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
| {-# OPTIONS_GHC -fno-warn-missing-signatures #-} | |
| module Main where | |
| import Control.Applicative | |
| import Text.Printf | |
| import Prelude hiding (and, or, flip) | |
| True `nand` True = False | |
| True `nand` False = True | |
| False `nand` True = True |
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 divisible-by? [x y] | |
| (zero? (mod x y))) | |
| (defn relative-prime? [coll x] | |
| (not-any? (partial divisible-by? x) | |
| (take-while (partial not= x) coll))) | |
| (defn generate-primes [n] | |
| (let [src (range 3 n 2) | |
| prime? (partial relative-prime? src)] |
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
| class Nothing(object): | |
| """Represents a failed computation. | |
| """ | |
| class TryChain(object): | |
| """Apply a series of functions to a value, keeping only the first one that | |
| fails to throw a user-specified exception. |
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
| The foo system consists of a master process, a supervisor, and some worker | |
| processes. The worker processes do a computationally expensive thing and send | |
| the results to the master process, which then maybe asks the supervisor to | |
| spawn more workers, depending on the result: | |
| ################ asks for workers... #################### | |
| # foo_master # ------------------------> # foo_supervisor # --\ | |
| ################ #################### | | |
| ^ | spawns.... |
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 multi-handler | |
| (:require [clojure.string :as string] | |
| [dire.core :refer [with-handler!]])) | |
| (defmacro with-multi-handler! | |
| "Make handlers for every exception in a collection" | |
| [handled exceptions body] | |
| (cons 'do | |
| (map | |
| #(list 'with-handler! handled % body) |
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
| #include <prime_generator.h> | |
| #include <iostream> | |
| unsigned long PrimeGenerator::next() | |
| { | |
| unsigned long factor; | |
| unsigned long next_composite; | |
| if (next_candidate >= max_value) { | |
| throw "Integer overfow!\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
| *.pyc |