Skip to content

Instantly share code, notes, and snippets.

View lerno's full-sized avatar

Christoffer Lerno lerno

View GitHub Profile
@lerno
lerno / tictac.c3
Created May 30, 2025 18:06
Tic tac toe
//-----------------------------------------------------------------------------
// Tic-Tac-Toe game by Syn9
// Tested with c3c 0.7.1
//-----------------------------------------------------------------------------
import std::io, std::math::random, std::os;
fn int util_rand_range(int lhs, int rhs) {
return lhs + rand(rhs - lhs); // [lhs, rhs)
}
@lerno
lerno / rock.c3
Created May 30, 2025 16:03
Rock paper..
import std::io;
import std::math::random;
fn int util_rand_range(int lhs, int rhs) {
return lhs + rand(rhs - lhs); // [lhs, rhs)
}
//-----------------------------------------------------------------------------
// Entry Point
//-----------------------------------------------------------------------------
@lerno
lerno / example.c3
Created January 24, 2024 21:50
Raylib
module abc;
import raylib;
import std::io;
const NUM_MODELS = 9;
fn void main()
{
// Initialization
//--------------------------------------------------------------------------------------
import std::io;
import std::collections::list;
define DoubleList = List<double>;
fn double test_list_on_heap(int len)
{
DoubleList list; // By default will allocate on the heap
defer list.free(); // Free at end
for (int i = 0; i < len; i++)
@lerno
lerno / threads.c
Last active December 11, 2022 17:17
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <pthread.h>
#include <stdbool.h>
static bool is_prime(int n) {
int i = 5;
@lerno
lerno / # php - 2022-10-03_12-51-36.txt
Created October 3, 2022 10:58
php on macOS 12 - Homebrew build logs
Homebrew build logs for php on macOS 12
Build date: 2022-10-03 12:51:36
// Copyright (c) 2020 Christoffer Lerno. All rights reserved.
// Use of this source code is governed by a LGPLv3.0
// a copy of which can be found in the LICENSE file.
#include "vmem.h"
#include "common.h"
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( _WIN64 )
#define PLATFORM_WINDOWS 1
#define PLATFORM_POSIX 0
@lerno
lerno / macro2.c
Created November 6, 2018 22:29
Macro proposal II
// Switch
macro char * @foo(&x) {
$switch (@typeof(x)) {
$case int: return "int";
$case float: return "float";
$default: return "???";
}
}
char *x = @foo(10); // char *x = "int";
@lerno
lerno / macro.c
Created November 6, 2018 21:48
Macro proposal
// 1. Macros with arguments
macro @foo(int &v) {
v++;
if (v > 10) return 10;
return v;
}
int bar() {
int a = 10;
@foo(a);
@lerno
lerno / gist:6d820600fbf30797ccf4
Last active August 29, 2015 14:15
Implicit unwrap vs optionals - trivial example to illustrate implicit conversion from "possibly null" to "not null" with annotations.
// Assume we also have the following:
void doSomethingWithFoo(@NotNull foo) { ... }
void doSomethingNull() { ... }
void doSomethingMore() { ... }
void doSomething(@Nullable Foo foo)
{
// doSomethingWithFoo(foo); <- this would have been an error in the IDE
// Since foo is @Nullable at this point
if (foo == null)