Skip to content

Instantly share code, notes, and snippets.

{-
Module : Newton
Description : Newton method in Haskell
Copyright : (c) Fabricio Olivetti de Franca, 2017
License : GPL-3
Maintainer : fabricio.olivetti@gmail.com
A simple implementation of the Newton's method.
-}
module Main where
newtype Identity a = Id a deriving Show
data DoubleF a = DoubleF a a deriving Show
instance Functor Identity where
fmap f (Id a) = Id (f a)
instance Functor DoubleF where
fmap f (DoubleF x y) = DoubleF (f x) (f y)
module Main where
import qualified Data.Set as S
-- hasMorph p m and hasMorph p n
isValid :: (a -> a -> Bool) -> (a -> a -> a) -> a -> a -> Bool
isValid f op x y = f p x && f p y
where p = x `op` y
#!/usr/bin/python
# pip install pyinterval
# pip install kaucherpy
from interval import interval
from kaucherpy import *
# the implementation of (**) in kaucherpy is wrong
# I'm using as a reference:
# https://www.dropbox.com/s/z6dlq60rq5t009k/MIC%20v2.1.zip?dl=0&file_subpath=%2FMIC+v2.1%2Ffstar%2Finterval.m
@folivetti
folivetti / python_wrapper_template.py
Created January 5, 2022 13:09
Example of a python wrapper for a symbolic regression cli
"""Example Scikit-learn compatible Python wrapper for a Symbolic Regression CLI.
This module demonstrates how to implement a python wrapper compatible with
scikit-learn for any Symbolic Regression CLI that returns a python compatible expression
in plain text.
This example assumes that your CLI allows to pass the parameters via command line
and that it returns a readable and python-compatible expression:
./bin/regressor 500 1000 0.3 0.7 42
import matplotlib.pyplot as plt
def SIR(S, I, beta, gamma, tot_time):
'''
S: susceptibles
I: infecteds
beta: contagion rate
gamma: recovery rate
tot_time: total time
'''
{
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: {
@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
#include <stdlib.h>
#include "lista.h"
#include "pilha.h"
PilhaDinamica *criar_pilha() {
PilhaDinamica *pilha = malloc(sizeof(PilhaDinamica));
pilha->topo = NULL;
return pilha;
}
#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;
}