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
(defclass user () | |
((name :reader user-name :initarg :name) | |
(roles :reader user-roles :initarg :roles))) | |
(defclass role () | |
((name :reader role-name :initarg :name))) | |
(defclass post () | |
((author-name :reader author :initarg :author) | |
(title :accessor post-title :initarg :title :initform nil) |
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
import numpy as np | |
from random import choice | |
def feed_forward(network, input, activation): | |
activations = [input] | |
output = input | |
for layer in network: | |
output = activation(np.dot(output, layer)) |
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
# sequence :: Monad m => [m a] -> m [a] | |
# | |
# a way of implementing this functionality is through a left fold | |
# that unwraps the each monad in the first list and accumulates it | |
# in the second list, rewrapped in the target monad: | |
# | |
# sequence actions = foldl unwrapAccumulateRewrap (return []) actions | |
# where unwrapAccumulateRewrap wrappedAccumulator action = | |
# wrappedAccumulator >>= \accumulator -> action >>= \value -> return (value : accumulator) | |
# |
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
use std::collections::HashMap; | |
enum Stmt { | |
Expr(Expr), | |
Let(Name, Expr), | |
} | |
struct Name(String); | |
enum Expr { |
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 grading-students | |
(:require [clojure.java.io :as io])) | |
(defn nearest-five [grade] | |
(let [increased (+ grade 5)] | |
(- increased | |
(mod increased 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
clj.core> (let [s1 (->> '(1 2 3) | |
(map #(do (println (* 10 %)) %)) | |
(map #(do (println %) %))) | |
] | |
s1) | |
10 | |
1 | |
20 | |
2 | |
30 |
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
package main | |
import ( | |
"fmt" | |
"time" | |
"sync" | |
"math/rand" | |
) | |
func main() { |
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
class Line | |
include Enumerable | |
delegate :each, to: :@elements | |
attr_reader :elements, :attributes | |
def initialize elements: [], attributes: {} | |
@elements = elements | |
@attributes = Attributes.new(**(attributes || {})) |
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 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
module queen | |
open util/time | |
open util/ordering[Player] | |
abstract sig Card{} | |
sig NormalCard extends Card{} | |
one sig FinalCard extends Card{} | |
sig Player{ succ : one Player } |
OlderNewer