Skip to content

Instantly share code, notes, and snippets.

View Ivana-'s full-sized avatar
🏠
Working from home

Андрей Ivana-

🏠
Working from home
View GitHub Profile
@Ivana-
Ivana- / cps.js
Created July 13, 2020 00:47
CPS in javascript (JavaScript Core, strict mode - for TCO)
"use strict";
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// волшебная троица
const cons = (x, y) => [x,y]
const car = (l) => l[0]
const cdr = (l) => l[1]
const nil = cons(null, null)
"""Minimal subnetwork."""
def minSubNetMask(ips):
m = 0
for ip in ips: m |= ips[0] ^ ip
full = (1 << 32) - 1 # 128 for IPv6
return (full << m.bit_length()) & full
def tst(ips, res):
r = minSubNetMask(ips) == res
@Ivana-
Ivana- / webinar2.clj
Created January 5, 2019 12:44
webinar 2 Clojure
(do
(def ones
(lazy-seq (cons 1 ones)))
(prn (take 10 ones))
(defn intfrom [n]
(lazy-seq (cons n (intfrom (+ 1 n)))))
@Ivana-
Ivana- / webinar2.js
Last active January 6, 2019 17:35
webinar 2 Javascript
print("\n\n\n")
// волшебная троица
const cons = (x, y) => [x,y]
const car = (l) => l[0]
const cdr = (l) => l[1]
// scons(h, t) = cons(h, lz(() => t))
@Ivana-
Ivana- / Infinite_data_structures.py
Last active February 25, 2020 22:34
Infinite data structures python
# https://www.onlinegdb.com/online_python_interpreter#
'''
-- immutable, persistent, coinductive streams
ones = 1 : ones
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
hamm = 1 : map (*2) hamm `f` map (*3) hamm `f` map (*5) hamm where
@Ivana-
Ivana- / TestTask.cpp
Created March 6, 2017 04:08
Тестовое задание в школу программистов C++
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
// компаратор пары в нужном порядке