Skip to content

Instantly share code, notes, and snippets.

View lrlucena's full-sized avatar
🦐
Working on Potigol Language (potigol.github.io)

Leonardo Lucena lrlucena

🦐
Working on Potigol Language (potigol.github.io)
View GitHub Profile
@lrlucena
lrlucena / Q01.rb
Last active October 7, 2015 04:27
Gabarito da Lista de Exercícios 12
# Escreva uma classe, chamada Ponto, que representa um ponto no
# plano cartesiano. A figura abaixo mostra quais atributos e métodos
# da classe.
class Ponto
attr_reader :x, :y
def initialize(x,y)
@x = x
@y = y
@mumoshu
mumoshu / read-a-file-using-stream.scala
Created December 9, 2011 00:58
Read a file using Stream (Scala)
import java.io.File
import java.io.FileInputStream
case class Chunk(length: Int, bytes: Array[Byte])
def fileContentStream(fileIn: FileInputStream): Stream[Chunk] = {
val bytes = Array.fill[Byte](1024)(0)
val length = fileIn.read(bytes)
Chunk(length, bytes) #:: fileContentStream(fileIn)
}
import scala.xml.{Node, Elem, Group}
/**
* A path to a Node in a Node tree.
*/
sealed trait NodePath {
def depth: Int
}
object NodePath {