Instantly share code, notes, and snippets.

# Antonio Pérez Barrero apbarrero

• Mallorca, ES
Created June 27, 2017 20:53
Defining functions over lists in practice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -module(lists1). -export([product/1, maximum/1]). product(Xs) -> product(Xs, 1). product([], P) -> P; product([X|Xs], P) -> product(Xs, X*P). maximum([X|Xs]) -> maximum(Xs, X). maximum([X|[]], M) -> max(X, M); maximum([X|Xs], M) -> maximum(Xs, max(X, M)).
Last active June 24, 2017 13:52
Tail recursion exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -module(tailrecurs). -export([fib/1, perfect/1, testPerfect/0]). fib(0) -> 0; fib(1) -> 1; fib(N) when N>1 -> fib(N, 1, 0). fib(2, Acc1, Acc2) -> Acc1 + Acc2; fib(N, Acc1, Acc2) when N>2 -> fib(N-1, Acc1 + Acc2, Acc1).
Created June 23, 2017 21:09
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -module(recurs). -export([fib/1, pieces/1]). fib(1) -> [0]; fib(2) -> [1,0]; fib(N) when N>2 -> L = fib(N-1), [X|Xs] = L,
Created June 21, 2017 20:17
First erlang program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -module(first). -export([double/1,mult/2,area/3,sq/1,treble/1]). mult(X,Y) -> X*Y. double(X) -> mult(2,X). area(A,B,C) ->
Created March 13, 2016 21:45
Array flatten
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 #!/usr/bin/env ruby require 'test/unit' def flatten(array) f = [] if array.kind_of?(Array) array.each{ |e| f.concat(e.kind_of?(Array) ? flatten(e) : [e]) } else f = [array]
Created June 22, 2014 07:24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 git log ..origin/
Created June 22, 2014 07:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Created August 26, 2013 07:06
Meaning of process state codes (C column) on `ps` output

# PROCESS STATE CODES

Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the state of a process.

CODE Meaning
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
Last active May 30, 2022 02:42
Legend for headers dumped by `ps -f` command