Skip to content

Instantly share code, notes, and snippets.

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

Jörn Dinkla jdinkla

🏠
Working from home
View GitHub Profile
@jdinkla
jdinkla / lhs2hs.groovy
Last active November 23, 2016 17:59
Convert literate Haskell (*.lhs) files to normal Haskell files (*.hs)
// (c) 2016 Jörn Dinkla, www.dinkla.net
// usage groovy lhs2hs.groovy FILENAMES.lhs
// warning: existing files with .hs extension are overwritten
void transformBeginEndCode(StringBuilder sb, File f) {
boolean inCode = false
sb << "{-\n"
f.text.eachLine { line ->
if (line =~ /^\\begin\{code\}/) {
sb << "-}\n\n"
inCode = true
@jdinkla
jdinkla / lambda_map.cu
Last active September 30, 2016 14:43
Using a __device__ lambda in CUDA 8.0
/*
* The following example shows the use of lambdas on the device with CUDA 8.0.
*
* needs the nvcc compiler option --expt-extended-lambda to compile.
*
* (c) 2016 Joern Dinkla, www.dinkla.net
*/
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
#include <thrust/transform.h>
@jdinkla
jdinkla / CovarianceContravariance.scala
Last active August 29, 2015 14:24
Covariance and Contravariance in Scala
// (c) 2015 Joern Dinkla, see http://www.dinkla.net/en/programming/scala-covariance-contravariance.html
abstract class Animal
class Cat extends Animal {
def meow() : Unit = println("meow")
}
class Dog extends Animal
def mkPair(a: Animal, b: Animal) = (a,b)
val ps = mkPair(new Cat, new Dog)