Skip to content

Instantly share code, notes, and snippets.

View arialdomartini's full-sized avatar

Arialdo Martini arialdomartini

View GitHub Profile
@arialdomartini
arialdomartini / squint.el
Created September 19, 2024 13:40
squint.el
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
(set-face-attribute 'default nil :height 100)
(set-face-attribute 'default nil :height 200)
;; ----------------------
@arialdomartini
arialdomartini / diamond.md
Last active September 5, 2024 19:58
Print Diamond Kata in PBT

Assumptions:

  • Function returns a list of strings.

  • Unless a requirement specifies spaces, it is intented to ignore them (e.g., "list is surrounded by an initial and an ending a" assumes that in this test any space in the initial and ending line is ignored.

  • The order of requirements matter, as it influences the

@arialdomartini
arialdomartini / main.rs
Created August 16, 2024 09:07
random fizz buzz
use std::fs::OpenOptions;
use std::io::Write;
use rand::{Rng, SeedableRng};
use rand_pcg::Pcg64;
fn fizz_buzz() -> impl Iterator<Item = String> {
(1..).map(|i| {
if i % 15 == 0 {
"fizzbuzz".to_string()
@arialdomartini
arialdomartini / Directory.Build.props
Last active July 24, 2024 04:11
Directory.Build.props
<Project>
<PropertyGroup>
<UseArtifactsOutput>true</UseArtifactsOutput>
</PropertyGroup>
</Project>
create database getting_started;
use getting_started;
create table employees (
id int,
last_name varchar(255),
first_name varchar(255),
primary key(id));
create table teams (
let tree = Node(Leaf "one", Node(Leaf "two", Leaf "three"))
type WithCount<'v> = WithCount of (int -> 'v * int)
let build l r = Node(l, r)
let run (WithCount f) (count: int)= f count
let pure' v = WithCount (fun count -> (v, count))
let (<*>) f a =
import Data.Monoid
-- questo importa Monoid che, semplificato, definisce lo zero e la concatenazione:
class Monoid a where
mempty :: a
mappend :: a -> a -> a
--questo mi permette di definire whatever tipo come monoide
newtype MyMonoid = ...
@arialdomartini
arialdomartini / linq+foreach.cs
Created March 11, 2024 17:38
linq_and_foreach.cs
public class VersionTest
{
private readonly ITestOutputHelper _outp;
public VersionTest(ITestOutputHelper outp)
{
_outp = outp;
}
[Fact]
f = 1: 1: zipWith (+) f (tail f)
@arialdomartini
arialdomartini / paolilleither.cs
Last active December 22, 2023 09:18
paolilleither.cs
internal interface Either<L, R>
{
Either<L, B> Bind<B>(Func<R, Either<L, B>> f);
B Match<B>(Func<L, B> whenLeft, Func<R, B> whenRight);
}
internal sealed record Right<L, R> : Either<L, R>
{