/* file: "tinyc.c" */ | |
/* originally from http://www.iro.umontreal.ca/~felipe/IFT2030-Automne2002/Complements/tinyc.c */ | |
/* Copyright (C) 2001 by Marc Feeley, All Rights Reserved. */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
/* |
translate([-30,0,0]) poly3d(sphere(r=9,$fn=80)); | |
translate([-10,0,0]) poly3d(normalized_cube(r=9,div_count=20)); | |
translate([10,0,0]) poly3d(spherified_cube(9,div_count=20)); | |
translate([30,0,0]) poly3d(icosahedron(9,n=4)); | |
module poly3d(p) { | |
polyhedron(points=p[0],faces=p[1]); | |
} | |
function normalize(v) = v / norm(v); // convert vector to unit vector |
(module | |
(func $addTwo (param i32 i32) (result i32) | |
(i32.add | |
(get_local 0) | |
(get_local 1))) | |
(export "addTwo" (func $addTwo))) |
use std::collections::VecDeque; | |
use std::str::FromStr; | |
#[derive(Debug, Clone)] | |
enum OperatorToken { | |
Plus, | |
Minus, | |
Multiply, | |
Divide, | |
} |
Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).
The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject
typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA
int doubler(int x) { | |
return 2 * x; | |
} |
*** SHED SKIN Python-to-C++ Compiler *** Copyright 2005-2013 Mark Dufour; License GNU GPL version 3 (See LICENSE)
infer.py: perform iterative type analysis
we combine two techniques from the literature, to analyze both parametric polymorphism and data polymorphism adaptively. these techniques are agesen's cartesian product algorithm [0] and plevyak's iterative flow analysis [1] '(the data polymorphic part)'. for details about these algorithms, see ole agesen's excellent Phd thesis [2]. for details about the Shed Skin implementation, see Mark
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x