Skip to content

Instantly share code, notes, and snippets.

View fstiffo's full-sized avatar

Francesco Stiffoni fstiffo

  • Sgajo - Agile Development & Consulting
  • Venice - Italy
View GitHub Profile
@fstiffo
fstiffo / aoc19-02.arr
Created December 13, 2019 11:51
Advent of Code 2019 Day 02 - Solution in Pyret
provide {
day-02 : day-02
}
end
include my-gdrive("aoc19-02-input.arr")
include string-dict
data Opcode:
| add
namespace NSMain;
function fuel(mass: Int) : Int
requires mass > 0;
{
return (mass / 3) - 2;
}
entrypoint function main(): [Int, Int] {
@fstiffo
fstiffo / parsed.txt
Created March 10, 2018 07:42
Sommas result of parsing
Table length: 63
Number of parses: 16
Parse Charts
Chart: 0
0: {SOMMAS → ● "[" SHORT_ABSTR "," RETHORICAL_TYPOLOGY "," EXTABST "]"}, from: 0
Chart: 1
0: {SOMMAS → "[" ● SHORT_ABSTR "," RETHORICAL_TYPOLOGY "," EXTABST "]"}, from: 0
1: {SHORT_ABSTR → ● SHORT_ABSTR$string$1 SENTENCE_LIST ")"}, from: 1
2: {SHORT_ABSTR$string$1 → ● "s" "h" "o" "r" "t" "_" "a" "b" "s" "t" "r" "("}, from: 1
#Match the results of sommas clause
@builtin "number.ne" # `int`, `decimal`, and `percentage` number primitives
@{%
var sommasObject = function (a,b,c) {
return function (d) {
return {"short_abstr": d[a], "rethorical_typology": d[b], "extabst": d[c]};
};
};
var appendItem = function (a, b) { return function (d) { return d[a].concat(d[b]); } };
@fstiffo
fstiffo / sortedtree.hs
Created October 6, 2017 07:55
Solution for #FLhaskell course 3.9
-- sortedtree.hs
-- Jeremy.Singer@glasgow.ac.uk
-- Example code for #FLhaskell course
-- Nodes contain integers, Leaves are empty
data Tree
= Leaf
| Node Int
Tree
Tree
deriving (Show)
import System.Random
{-
A little more generic version of the Bulls and Cows
guessing game.
To reproduce the original game simply call:
bullandcows 4 "123456789"
For a detailed description of the game look at:
import System.Random
wordlist = ["awkward","bagpipes","banjo","bungler","croquet","crypt",
"dwarves","fervid","fishhook","fjord","gazebo","gypsy",
"haiku","haphazard","hyphen","ivory","jazzy","jiffy",
"jinx","jukebox","kayak","kiosk","klutz","memento",
"mystify","numbskull","ostracize","oxygen","pajama",
"phlegm","pixel","polka","quad","quip","rhythmic","rogue",
"sphinx","squawk","swivel","toady","twelfth","unzip","waxy",
"wildebeest","yacht","zealous","zigzag","zippy","zombie"]
@fstiffo
fstiffo / Runtime errors.txt
Created September 2, 2017 08:27
Runtime error
×
TypeError: xs is undefined
make/newrecord[9]
src/game.re:176
173 | var newrecord = component.slice();
174 | newrecord[/* render */9] = (function (self) {
175 | var history = self[/* state */3][/* history */0];
> 176 | var current = Caml_array.caml_array_get(history, self[/* state */3][/* stepNumber */2]);
177 | var winner = calculateWinner(current);
@fstiffo
fstiffo / commentConfirmation.re
Created August 23, 2017 08:34
Reason React first component try
let component = ReasonReact.statefulComponent "CommentConfirmation";
type state = {showConfirm: bool};
let make ::onConfirm children => {
let toggleConfirmMessage _event {ReasonReact.state: state} =>
ReasonReact.Update {showConfirm: not state.showConfirm};
let confirmAction _event _self => {
onConfirm;
ReasonReact.Update {showConfirm: false}
@fstiffo
fstiffo / npm-debug.log
Created August 21, 2017 18:43
Error after installing reson-cli binaires
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'https://github.com/reasonml/reason-cli/archive/beta-v-1.13.6-bin-linux.tar.gz' ]
2 info using npm@3.10.10
3 info using node@v6.11.2
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree