def hash(a: A): Int
makes me sad. What about hashing to 64 bits or SL2 Fp?def MapHash[A, B: Hash]: Hash[Map[A, B]]
is a bit odd. Why notA: Hash
?reflexiveLaw + symmetryLaw + transitivityLaw
is too weak for "equality". This defines a general equivalence relationship only.val AnyEqual: Equal[Any]
is worrisome, considering all the resolution bugs!val DoubleEqual: Equal[Double]
should be implemented usingjava.lang.Double.doubleToRawLongBits
.- A combintation of [
trait Ord[-A] extends Equal[A]
](https://github.com/zio/zi
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
;; stage :: (name : String) -> (description : String) -> Stage | |
;; principle :: (name : String) -> (description : String) -> Principle | |
;; strategy :: (name : String) -> (description : String) -> (parent_principles: List String) -> Strategy | |
;; tactic :: (name : String) -> (description : String) -> (parent_strategies_and_principles: List String) -> Tactic | |
; The Principle-Strategy-Tactic axis represents a hierarchical framework for reasoning and problem-solving, moving from abstract, foundational beliefs to concrete, actionable steps. | |
; **Principles** are the most abstract level, representing foundational beliefs or philosophies that guide reasoning and decision-making across various contexts. They are timeless and universal, providing a conceptual framework from which strategies and tactics can be developed. Principles are not directly actionable but serve as the bedrock for strategic thinking and tactical execution. |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
import numpy as np | |
import matplotlib.pyplot as plt | |
########################################################## | |
# Generating training and validation data |
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 geocoder | |
import geopy.distance | |
import requests | |
import time | |
import json | |
def now(): | |
from datetime import timezone | |
import datetime | |
dt = datetime.datetime.now(timezone.utc) |
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
sealed class StableName[A] extends Serializable | |
object StableName { | |
private[this] final class RefInstance[A <: AnyRef](val value: A) extends StableName[A] { | |
override def clone(): AnyRef = this | |
override def equals(obj: Any): Boolean = obj match { | |
case that: RefInstance[_] => that.value eq this.value | |
case _ => false | |
} |
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
#include <iostream> | |
#include <cmath> | |
#include <vector> | |
#include <cassert> | |
#include <memory> | |
enum NodeOp { | |
OP_CONST, | |
OP_ADD, | |
OP_MUL, |
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
@numba.jit("i4(i4, i4)", nopython=True, nogil=True) | |
def gcd(a, b): | |
while True: | |
if a == 0: return b | |
if b == 0: return a | |
if a == b: return a | |
if b > a: | |
a, b = a, b % a | |
else: | |
a, b = a % b, b |
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
sealed trait Free[+F[_], A] | |
object Free { | |
def eval[F[_], A](fa: Free[F, A])(implicit F: Monad[F]): F[A] = { | |
type State = (Free[F, Any], List[Any => Free[F, Any]]) | |
def go(s: State): F[Either[State, Any]] = s match { | |
case (current, stack) => | |
current match { | |
case Done(a) => | |
stack match { | |
case 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
/////////////////////////////////////////////////////////////////// | |
// STEP 1 - Evaluation by need monad | |
/////////////////////////////////////////////////////////////////// | |
import scala.annotation.unchecked.{ uncheckedVariance => uV } | |
final class Need[+A](private[this] var thunk: Need.Thunk[A @uV]) { A => | |
import Need._ | |
def value: A = thunk match { | |
case Done(x) => x |
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 sums up my understanding of | |
// https://github.com/lampepfl/dotty/issues/9359 | |
// and https://github.com/lampepfl/dotty/issues/8430 | |
// == on AnyVal does not imply singleton type equality | |
class Test[A](val x: Int) extends AnyVal | |
def coerce1[A, B](a: A): B = { | |
val x = new Test[A](1) | |
val y = new Test[B](1) |
NewerOlder