Skip to content

Instantly share code, notes, and snippets.

View danilomo's full-sized avatar

Danilo Oliveira danilomo

View GitHub Profile
@danilomo
danilomo / gist:07779d8cf28e067f47ee98f1c3432583
Last active March 1, 2018 10:14
.emacs with a new untitled buffer in text mode and *GNU Emacs* and *scratch* killed
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
@danilomo
danilomo / Graph.scala
Last active July 26, 2017 08:11
Functional Graph API in Scala, using edge list as representation
/**
* A functional Graph object in Scala, for learning purposes.
*/
class Graph[V,W](val vertices: List[V], val edges: List[(V,V,W)]) {
override def toString(): String = vertices.toString() + ", " + edges.toString()
def addVertex(v: V): Graph[V,W] = Graph( v :: this.vertices, this.edges )
def addEdge(e: (V,V,W)): Graph[V,W] = Graph(this.vertices, e :: this.edges )
@danilomo
danilomo / Range2.java
Last active July 18, 2017 09:52
Finds which sub-interval contains a given value. Flexible solution
interface Command {
public void execute();
public static final Command EMPTY = new Command() {
@Override
public void execute() {
// do nothing.
}
};
}
@danilomo
danilomo / Range.java
Last active July 18, 2017 09:52
Finds which sub-interval contains a given value. Hardcoded X flexible solution
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class HardcodedRangeTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
@danilomo
danilomo / distances.hs
Last active May 24, 2017 14:30
Find the closest vector in a list to a given vector v
type Vector3D = (Float, Float, Float)
arr :: [ Vector3D ]
arr = [ ( 35, 30, 39 ),( 20, 12, 5 ) ]
tp :: Vector3D
tp = (19,13,3)
dist:: Vector3D -> Vector3D -> Float