Skip to content

Instantly share code, notes, and snippets.

View radustoenescu's full-sized avatar

Radu Stoenescu radustoenescu

  • Politehnica Bucharest
  • Bucharest
View GitHub Profile
@radustoenescu
radustoenescu / gist:4107307
Created November 18, 2012 20:42
Queens problem in Scala
object Queens {
def main(args: Array[String]): Unit = {
println(queens(9))
}
def queens(n: Int): List[List[Int]] = {
def expandSol(currentSol: List[List[Int]], size: Int): List[List[Int]] = {
if (size == n)
firewall :: IPClassifier(dst tcp port ssh,-);
in :: FromDevice(dev0) -> cl :: Classifier(12/0800,-);
cl[0] -> stripper :: Strip(14) -> checker :: CheckIPHeader -> firewall;
cl[1] -> discarder :: Discard;
firewall[0] -> out :: ToDevice(dev1);
firewall[1] -> discarder;
-- Elements
firewall :: IPClassifier(dst tcp port ssh,-);
in :: FromDevice(dev0) -> cl :: Classifier(12/0800,-);
cl[0] -> counter :: AverageCounter(2) -> stripper :: Strip(14) -> checker :: CheckIPHeader -> firewall;
cl[1] -> discarder :: Discard;
firewall[0] -> out :: ToDevice(dev1);
firewall[1] -> discarder;
goes to:
import java.util.ArrayList;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
MyStack s = new MyStack();
@radustoenescu
radustoenescu / gist:8956545
Created February 12, 2014 14:30
Key ideas and concepts
Boxed types and specialization in Scala
@radustoenescu
radustoenescu / gist:9653203
Last active August 29, 2015 13:57
Types Lab 2
{- 1. write an ADT which encodes arithmetic expressions containing +, * or parentheses -}
data Expr a =
{-- 2. display an expression nicely --}
instance Show a => Show (Expr a) where
{- 3. write a function which evaluates an expression. Also, write it's type -}
{- 4. Write a function which eliminates parentheses from an expression.
e * (3) = e * 3
@radustoenescu
radustoenescu / Lab streams
Last active August 29, 2015 13:58
Lab of infinite lists in scheme
; delay construct
(define doi (delay (+ 1 1)))
; force a delay to compute its result
(force doi)
; cons for streams
(define-syntax conss
(syntax-rules ()
((conss x y)
ctors return an object
anonymous objects
returning by const
uses of const:
1. immutability of param
2. immutability of returned object
3. immutability of 'this'
return consts from getters !
%% ----------------------------------------
%% ----------------------------------------
%% Atenție la antetele predicatelor și la prefixul parametrilor
%% p(+Arg1, -Arg2, ?Arg3)
%% * Arg1 va fi instanțiat atunci când se va încerca satisfacerea p/3
%% * Arg2 se va instanția odată cu satisfacerea p/3
%% * Arg3 va putea fi instanțiat sau nu atunci când se va satisface p/3:
%%
%% Interogați Prolog cu "checkXX." pentru a verifica rezolvarea exercițiului XX.
%% Pentru a vedea progresul general, trimiteți scopul "check_all".
Click can be found @ http://www.read.cs.ucla.edu/click/
Click paper @ https://pdos.csail.mit.edu/papers/click:tocs00/paper.pdf
======================================================================
sudo apt-get update
sudo apt-get install git build-essential
git clone https://github.com/kohler/click.git
cd clikc