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
(defgeneric add (x y)) | |
;;; assume we already defined vector and integer classes | |
(defmethod add ((x vector) (y vector)) | |
....) | |
(defmethod add ((x integer) (y integer)) | |
(+ x y)) |
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
namespace FN_impl { | |
template<class T> | |
constexpr auto delay(auto x) { | |
return x; | |
} | |
struct no_arg_passed { | |
template<class T> | |
operator T() { |
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
template<class T, class Less = std::less<>> | |
constexpr auto minmax(T&& x, T&& y, Less less = {}) | |
BODX(less(y, x) ? std::forward_as_tuple(y, x) : std::forward_as_tuple(x, y)) | |
// s is for stable | |
template<class T, class Less = std::less<>> | |
constexpr auto smin(T&& x, T&& y, Less less = {}) | |
BODX(std::get<0>(minmax(x, y, less))) | |
template<class T, class Less = std::less<>> |
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 logic-data-transform.core | |
(:use [clojure.core.logic]) | |
(:require [clojure.test :as test]) | |
(:require [clojure.core.match :refer [match]])) | |
(defn assoco | |
([base & args] | |
(let [out (last args) | |
bindings (partition 2 (butlast args))] | |
(apply conjo base (conj (vec bindings) out))))) |
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
#!/usr/bin/env python | |
def is_even(x): | |
return x & 1 | |
def gcd(x,y): | |
factors_of_2 = 0 | |
while true: | |
if x==0: | |
return y << factors_of_2 |
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 "hedley.h" | |
// https://www.fluentcpp.com/2019/08/30/how-to-disable-a-warning-in-cpp/ | |
#include <initializer_list> | |
//#pragma GCC diagnostic error "-Wshadow" | |
#define PRAGMA_IGNORE_SHADOW_GCC \ | |
_Pragma("GCC diagnostic ignored \"-Wshadow\"") | |
#define MSVC_DISABLE_WARNING(num) __pragma(warning(disable : num)) |
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
int f(int count, int data) { | |
count += calc_adjustment(data); | |
UMBRA_FREEZE(count) { g(count) } | |
} | |
// ==> | |
int f(int count, int data) { | |
count += calc_adjustment(data); | |
if(auto const& umbra_gensym1tmp = count; true) | |
UMBRA_IGNORE_SHADOW( // |
OlderNewer