Skip to content

Instantly share code, notes, and snippets.

@folivetti
folivetti / rec.hs
Created April 14, 2023 11:02
rec schemes
{-# language TupleSections #-}
module Main where
data ListF a b = NilF | ConsF a b deriving Functor
data NatF a = ZeroF | SuccF a deriving Functor
data StreamF a b = StreamF a b deriving Functor
newtype Fix f = Fix {unfix :: f (Fix f)}
type Algebra f a = f a -> a
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int cmpfunc (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
void insert(int *arr, int n) {
int x = arr[n];
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) (a > b ? a : b)
typedef struct LinkedList {
int val;
struct LinkedList *next;
} LinkedList;
#include <stdio.h>
#include <stdlib.h>
#define max(a, b) (a > b ? a : b)
typedef struct LinkedList {
int val;
struct LinkedList *next;
} LinkedList;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct LinkedList {
int val;
struct LinkedList *next;
} LinkedList;
LinkedList * create_node(int x) {
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(int argc, char *argv[]) {
int n, min, max, x, i;
time_t t;
srand((unsigned) time(&t));
#include <stdlib.h>
#include "lista.h"
#include "fila.h"
FilaDinamica *criar_fila() {
FilaDinamica *fila = malloc(sizeof(FilaDinamica));
fila->inicio = NULL;
fila->fim = NULL;
return fila;
}
#include <stdlib.h>
#include "lista.h"
#include "pilha.h"
PilhaDinamica *criar_pilha() {
PilhaDinamica *pilha = malloc(sizeof(PilhaDinamica));
pilha->topo = NULL;
return pilha;
}
@folivetti
folivetti / Main.hs
Created September 22, 2022 12:17
minimal example that hangs hegg
{-# language DeriveTraversable #-}
{-# language LambdaCase #-}
{-# language TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleInstances #-}
module Main (main) where
import Data.Eq.Deriving
{
description = "ITEA";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/master";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
config = {
packageOverrides = pkgs: {