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 / ex3_05.erl
Created March 6, 2017 09:35
FUNCTIONAL PROGRAMMING IN ERLANG THE UNIVERSITY OF KENT (WEEK 3 STEP 5) - Solutions
-module(ex3_05).
-export([double_all/1,evens/1,product/1,test/0]).
%% First part: using higher-order functions
-spec double_all(list(number())) -> list(number()).
double_all(L) -> lists:map(fun(X) -> X * 2 end, L).
-spec evens(list(integer())) -> list(integer()).
evens(L) -> lists:filter(fun(X) -> X rem 2 == 0 end, L).
-module(rps).
-export([best_strategy/1, cycle/1, echo/1, enum/1,
frequencies/1, least_frequent/1, more_frequent/1,
no_repeat/1, play/1, play_two/3, rand/1,
rand_strategy/1, rock/1, show_play_two/3, tournament/2,
val/1]).
-type play() :: rock | paper | scissors.
Purtroppo la bizzarra gestione delle porte USB su Raspberry Pi Zero (ora sono tipo micro e una sola di fatto), che obbliga all'acquisto
di una scheda di espansione con le porte USB "normali", lo hanno reso di fatto poco interessante.
Il collegamento via Bluetooth lo sconsiglio: costo dei controller, possibili latenze, e non dimentichiamo che è sempre roba che
va messa in mano a dei bambini (pile, sportellini, ecc.).
Si deve giocoforza ripiegare sul più caro Pi 3 Model B che costa circa 20€ in più. :(
Su Amazon il Kit completo più economico (e che straconviene) include:
1. Raspberry Pi 3 Model B
-module(palin).
-export([nopunct/1, palin/1, palindrome/1, server/1]).
% palindrome problem
%
% palindrome("Madam I\'m Adam.") = true
palindrome(Xs) -> palin(nocaps(nopunct(Xs))).
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0]).
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0]).
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0]).
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/0,allocate/0,deallocate/1,stop/0]).
%% Based on code from
%% Erlang Programming
%% Francecso Cesarini and Simon Thompson
%% O'Reilly, 2008
%% http://oreilly.com/catalog/9780596518189/
%% http://www.erlangprogramming.org/
%% (c) Francesco Cesarini and Simon Thompson
-module(frequency).
-export([start/1,allocate/0,deallocate/1,stop/0]).
@fstiffo
fstiffo / swagger.yaml
Created August 13, 2017 07:29
API definition for VENSES service
---
swagger: "2.0"
info:
description: "This is a simple API to acceess VENSES entailment service"
version: "1.0.0"
title: "VENSES API"
contact:
email: "info@sgajo.com"
license:
name: "Apache 2.0"