This file contains hidden or 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
    
  
  
    
  | # http://badhessian.org/2012/09/lessons-on-exponential-random-graph-modeling-from-greys-anatomy-hook-ups/ | |
| library(ergm) | |
| path <- "/Users/juarez.bochi/Dropbox/mestrado/inf2035/Random Graphs/fbergm" | |
| friends_path <- paste(path, "friends_manual.tsv", sep="/") | |
| relationships_path <- paste(path, "relationships.tsv", sep="/") | |
| friends <- read.table(friends_path, sep="\t", header=T, stringsAsFactors=F, strip.white=F, as.is=T) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | PriorityQueue <- function() { | |
| keys <<- values <<- NULL | |
| insert <- function(key, value) { | |
| temp <- c(keys, key) | |
| ord <- order(temp) | |
| keys <<- temp[ord] | |
| values <<- c(values, list(value))[ord] | |
| } | |
| pop <- function() { | |
| key <- keys[[1]] | 
  
    
      This file contains hidden or 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
    
  
  
    
  | <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
| <title> - jsFiddle demo</title> | |
| <script type='text/javascript' src='/js/lib/dummy.js'></script> | |
| <link rel="stylesheet" type="text/css" href="/css/normalize.css"> | |
| <link rel="stylesheet" type="text/css" href="/css/result-light.css"> | 
  
    
      This file contains hidden or 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
    
  
  
    
  | def ifilter(funcao, seq): | |
| for x in seq: | |
| if funcao(x): | |
| yield x | |
| def take(seq, n): | |
| i = 0 | |
| for x in seq: | |
| if i < n: | 
  
    
      This file contains hidden or 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
    
  
  
    
  | class Natural(object): | |
| def __init__(self, anterior): | |
| self.anterior = anterior | |
| def __str__(self): | |
| return str(self.anterior) + " + 1" | |
| def __add__(self, other): | |
| return self.anterior + other.sucessor() | 
  
    
      This file contains hidden or 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
    
  
  
    
  | def change(n, coins): | |
| if n == 0: | |
| return 1 | |
| elif n < 0 or len(coins) == 0: | |
| return 0 | |
| else: | |
| return change(n, coins[1:]) + change(n - coins[0], coins) | |
| print change(10, [10, 5, 2, 1]) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | #from functools import partial | |
| def partial(funcao, argumento): | |
| def fn(arg): | |
| return funcao(argumento, arg) | |
| return fn | |
| def to_tag(tag, texto): | |
| return "<{tag}>{texto}</{tag}>".format(tag=tag, texto=texto) | |
| negrito = partial(to_tag, 'b') | 
  
    
      This file contains hidden or 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
    
  
  
    
  | def print_pascal_triangle(n_lines): | |
| for row in xrange(n_lines): | |
| for col in xrange(row + 1): | |
| print pascal(row, col), | |
| def pascal(row, col): | |
| if col == 0 or row == col: | |
| return 1 | 
  
    
      This file contains hidden or 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
    
  
  
    
  | def msort(xs: List[Int]): List[Int] = { | |
| val n = xs.length / 2 | |
| if (n == 0) xs | |
| else { | |
| def merge(xs: List[Int], ys: List[Int]): List[Int] = (xs, ys) match { | |
| case (Nil, ys) => ys | |
| case (xs, Nil) => xs | |
| case (x :: xs1, y :: ys1) => | |
| if (x < y) x :: merge(xs1, ys) | |
| else y :: merge(xs, ys1) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | class O(): | |
| def __repr__(self): | |
| return "<" + ' *o* '.join(map(repr, self.funs)) + ">" if self.funs else "<composer>" | |
| def __init__(self, funs=None): | |
| self.funs = funs if funs else [] | |
| def __rmul__(self, other): | |
| other_funs = other.funs if isinstance(other, O) else [other] | |
| return O(other_funs + self.funs) |