Skip to content

Instantly share code, notes, and snippets.

View B1Z0N's full-sized avatar
🐢
contemplating

Mykola Fedurko B1Z0N

🐢
contemplating
View GitHub Profile
@B1Z0N
B1Z0N / zipper.cpp
Created June 30, 2019 23:16
generic zip iterator for simple zipping in c++
#include <vector>
#include <tuple>
#include <iostream>
using namespace std;
template <
typename T1,
typename T2,
#include <functional>
#include <iostream>
using namespace std;
template <typename... RetTs, typename... ArgTs>
auto _for_each(std::function<RetTs(ArgTs...)>... funcs)
{
return [ = ] (ArgTs... args) {
return tuple {
@B1Z0N
B1Z0N / container_printer.cpp
Last active July 19, 2019 11:41
customizable recursive container print
// code that looks common enough for me to write and post it here
// printing iterable of iterable/values of ... to ostream object
// works on any std conatiner and on any class that meets
// the requirements of Container(named requirement)
// ======================================================================
// compile with g++ container_printer.cpp -o container_printer -std=c++17
// other compilers not guaranteed to compile this
// ======================================================================
@B1Z0N
B1Z0N / max_min_var.cpp
Last active July 19, 2019 11:41
finding maximal and minimal element in variadic number of arguments
// finding maximal and minimalelement in variadic number of arguments
#include <iostream>
namespace cmns {
// commons
// *************MAXIMAL*VALUE*FUNCTIONS****************
@B1Z0N
B1Z0N / template_traits.hpp
Created July 24, 2019 00:39
c++ template traits implemented for better understanding
#include <utility>
//*********************TRANSFORMATION*TRAITS***************************
// Remove reference
template <typename T>
@B1Z0N
B1Z0N / trait_factory.cpp
Created July 24, 2019 21:27
Code for generation of predicate traits
// Code for generation of predicate traits
// compile with g++ -std=c++17 ...
#include <utility>
#include <vector>
#include <iostream>
// ***************IMPLEMENTATION***************
@B1Z0N
B1Z0N / cloudSettings
Last active December 3, 2019 21:19
Visual Studio Code Settings Sync Gist as of 3 of December 2019
{"lastUpload":"2019-12-03T21:06:53.375Z","extensionVersion":"v3.4.3"}
@B1Z0N
B1Z0N / currying.js
Created December 4, 2019 05:44
Some functional concepts implemented in js
'use strict';
const curry = (f) => {
const argc = f.length;
if (argc === 1) {
return f;
}
return (a) => curry(f.bind(null, a), argc - 1);
};
@B1Z0N
B1Z0N / bit_shortcuts.cpp
Created February 2, 2020 13:23
The collection of useful bit operations for speed and sanity purposes
// Number of leading zeroes: builtin_clz(x)
// Number of trailing zeroes : builtin_ctz(x)
// Number of 1-bits: __builtin_popcount(x)
// The parity (even or odd) of the number of ones: __builtin_parity(x)
// a * 2^n
constexpr int multiplyByPowerOf2(int a, int n) {
return a << n;
}
@B1Z0N
B1Z0N / competitive.cpp
Last active February 23, 2020 17:57 — forked from kodekracker/c++Template.cpp
Basic C++ Template for Competitive Programming
/*
___,,___
,d8888888888b,_
_,d889' 8888b,
_,d8888' 8888888b,
_,d8889' 888888888888b,_
_,d8889' 888888889'688888, /b
_,d8889' 88888889' `6888d 6,_
,d88886' _d888889' ,8d b888b, d\
,d889'888, d8889' 8d 9888888Y )