View HM.hs
{-# LANGUAGE TupleSections #-}
import Control.Monad.State (State, evalState, get, gets, modify, put)
import Data.Function (on)
import Data.List (unionBy)
import Data.Map (Map)
import Data.Maybe (fromMaybe)
import qualified Data.Map as Map
View fireworks.html
<!DOCTYPE html>
<html>
<head>
<title>Fireworks</title>
</head>
<body>
<script>
const SCRW = 800;
const SCRH = 800;
View fibo.py
class Vec2(object):
def __init__(self, x, y):
self.x = x
self.y = y
def dot(v, w):
return v.x * w.x + v.y * w.y
class Mat22(object):
def __init__(self, a, b, c, d):
View ondulator.html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Ondulator</title>
<script>
const PI = Math.PI;
const TAU = 2 * PI;
View Fruits.hs
import Data.SBV
fruits :: SInteger -> SInteger -> SInteger -> SBool
fruits a b c = equation &&& positive
where
x = sFromIntegral a :: SReal
y = sFromIntegral b :: SReal
z = sFromIntegral c :: SReal
equation = x / (y + z) + y / (x + z) + z / (x + y) .== 4
View Circle.hs
import Control.Monad
import Math.NumberTheory.Logarithms (integerLog2)
simulate :: Integer -> Integer
simulate n = head (go [1..n])
where
go [x] = [x]
go (x1:x2:xs) = go (xs ++ [x1])
View out_of_process.py
def out_of_process(func):
from types import GeneratorType
GENERATOR = b'#GENERATOR#'
DONE = b'#DONE#'
def runner(conn, *args, **kwargs):
return_value = func(*args, **kwargs)
if isinstance(return_value, GeneratorType):
conn.send(GENERATOR)
for val in return_value:
View wrap_wrap.cpp
#include <type_traits>
template <typename T>
struct wrap;
template <typename T>
constexpr auto is_wrap_v = false;
template <typename T>
constexpr auto is_wrap_v<wrap<T>> = true;
View JavaStringMemchr.java
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class Program {
private static final Unsafe UNSAFE;
View novice-tuple.cpp
#include <utility>
#include <type_traits>
template<typename T>
struct identity { using type = T; };
template<std::size_t I, typename... Ts>
struct nth_type;
template<typename T, typename... Ts>