Skip to content

Instantly share code, notes, and snippets.

Sven Nilsen bvssvni

Block or report user

Report or block bvssvni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bvssvni
bvssvni / test.idr
Created Apr 4, 2017
Attempt to generate a function type
View test.idr
data PathType = NAT | BOOL
interpPathType : PathType -> Type
interpPathType NAT = Nat
interpPathType BOOL = Bool
Func : Type
Func = (List PathType, PathType)
interp : Func -> Type
@bvssvni
bvssvni / test.rs
Last active Jan 17, 2017
YEAH! It compiles!
View test.rs
pub fn par_trans2(
pos: V2<f32>,
f: Box<Fn(&[V2<f32>], &mut [bool]) + Sync>
) -> Box<Fn(&[V2<f32>], &mut [bool]) + Sync>{
const SIZE: usize = 1024;
Box::new(move |input, output| {
input.par_chunks(SIZE)
.zip(output.par_chunks_mut(SIZE))
.for_each(|(i, o): (&[V2<f32>], &mut [bool])| {
/// Use stack memory to avoid allocations.
View gist:10a1cf737fcea6feca2a14c79bf05767
$ cargo publish --verbose
Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to update registry https://github.com/rust-lang/crates.io-index
Caused by:
failed to fetch `https://github.com/rust-lang/crates.io-index`
Caused by:
[9/-3] Object not found - no match for id (af86e67bfa42abc6f7362a4f1de845b4e3a943f3)
@bvssvni
bvssvni / syntax.txt
Created Jan 3, 2017
Syntax for a subset of English that is activity focused
View syntax.txt
_seps: "."
8 sentence = [activity:"activity" .w? "."]
9 expression = .s!([.w! {"&":"&" "|":"|"} .w!] activity:"term")
10 if = [{"if" "when"} .w! expression:"condition" .w! "then" .w! expression:"then"
.r?([.w! "else" .w! "if" .w! expression:"else_if_condition" .w!
"then" .w! expression:"else_if_then"])
?[.w! "else" .w! expression:"else"]]
11 activity = [!{"then" "else" "&" "|"} {
if:"if"
@bvssvni
bvssvni / watch.sh
Created Jan 2, 2015
Cross platform watch script for Rust - updated for `cargo build`
View watch.sh
#!/bin/bash
#written by zzmp
# This script will recompile a rust project using `cargo build`
# every time something in the specified directory changes.
# Watch files in infinite loop
watch () {
UNAME=$(uname)
@bvssvni
bvssvni / example.rs
Last active Sep 17, 2016
Major breakthrough in path semantics: First working prototype of dependently paths!!!!
View example.rs
/*
Diary, Sven Nilsen, 15.09.2016:
Reading mathematical papers does help.
Woke up with an idea that arguments could be represented as tuples.
This idea turned into functional currying.
Started coding from scratch today (in Rust of course!) and came this far.
I think I'm starting to understand how dependently types work!
Path semantics is a new field that might make dependently types more powerful and practical.
@bvssvni
bvssvni / deep_learning.rs
Last active May 6, 2016
A pre-training example for deep learning in Dyon
View deep_learning.rs
fn sigmoid(x) -> {
return 1 / (1 + exp(-x))
}
fn layer(inputs, outputs) -> {
return [[0; inputs]; outputs]
}
fn tensor(sizes) -> {
@bvssvni
bvssvni / helper.rs
Created Feb 18, 2016
helper module for OpenGL
View helper.rs
// Version 0.0.1
use gl;
use gl::types::*;
use std::ffi::CString;
pub fn create_program(
vertex_shader: &str,
fragment_shader: &str
) -> Result<GLuint, String> {
@bvssvni
bvssvni / main.rs
Last active Jan 22, 2016
working on a home made scripting language - name suggestions?
View main.rs
fn set_x(a: 'return, val: 'a) -> {
a.x = val
return val
}
fn main() {
y := {x: {0: 0}}
set_x(y, {0: 2}) // ERROR: Requires reference to variable
println(y)
}
You can’t perform that action at this time.