Skip to content

Instantly share code, notes, and snippets.

vec4 mat4_col(const mat4 *m, int c)
{
vec4 res;
res.x = m->frows[0][c];
res.y = m->frows[1][c];
res.z = m->frows[2][c];
res.w = m->frows[3][c];
return res;
}
#include <stdio.h>
#include <item/ast.h>
#include <item/io.h>
int main(int argc, char **argv)
{
item_mod *mod = item_create_mod();
item_type *i32 = item_e2b(item_get_int(mod, 32));
item_fun *fun = item_create_fun(mod, i32, "main", L_GLOBAL);
@antonijn
antonijn / path.c
Last active April 10, 2017 18:54
PATH interpreter
#include<stdio.h>
#define b ;break;case
#define w (c=getc(f))
int c,x=1,y,u,r=1;char m[30000],*s=m;int main(int i,char**j){FILE*f=fopen(j[1],"r");while(w-'$'){++x;y+=c=='\n'?x=1:0;}for(;;){switch w{case'#':return fclose(f);b'\\':i=u;u=-r;r=-i;b'/':i=u;u=r;r=i;b'}':s++b'{':s--b',':*s=getchar()b'.':putchar(*s)b'^':u=*s?(r=0)+1:u;b'<':r=*s?(u=0)-1:r;b'v':u=*s?(r=0)-1:u;b'>':r=*s?(u=0)+1:r;b'+':++*s;b'-':--*s;b'!':x+=r;y-=u;}x+=r;y-=u;rewind(f);for(i=0;i<y;i+=w=='\n');for(i=0;i<x;++i)w;}}
import Data.Char
writeOut :: Int -> String
writeOut 1 = "one"
writeOut 2 = "two"
writeOut 3 = "three"
writeOut 4 = "four"
writeOut 5 = "five"
writeOut 6 = "six"
@antonijn
antonijn / test.c
Last active August 29, 2015 14:07
acc <3
int main(void)
{
int i = 1 + 2;
int j = i + 1;
if (j)
return i;
return j;
}
enum sound {
CONSONANT,
SHORT_VOWEL,
LONG_VOWEL,
};
enum sound getsound(FILE *word)
{
int ch = fgetc(word);
if (isconsonant(ch))
@antonijn
antonijn / k&r.c
Last active August 29, 2015 14:07
Compiles with gcc
extern puts();
main(argc, argv)
int argc;
char **argv;
{
return puts("Hello, world!") >= 0;
}
@antonijn
antonijn / c.c
Created September 10, 2014 22:36
int main(void)
{
int i;
for (i = 0; i < 10; ++i)
;
return i;
}
struct foo {
int i;
};
int main(void)
{
struct foo bar;
int i;
for (i = 0; i < 10; i++)
continue;
@antonijn
antonijn / ace.c
Last active August 29, 2015 14:05
The ACE superset
#ifndef __ACE__
#error ACE is required to compile this unit
#endif
// Line comments are allowed!
// Defines symbols to make code more readable
#include <ace.h>
#include <string.h>