Skip to content

Instantly share code, notes, and snippets.

@luiscubal
luiscubal / closure_idivide.lara
Created October 8, 2015 19:01 — forked from joaobispo/closure_idivide.lara
LARA Example - idivide
// Replaces division operations in closure function with a MATISSE primitive that performs integer division
sequencedef closure_idivide
select function{"closure"} end
apply
call replace_operator("/", "N", "2", "matisse_idivide");
// Implicit update here
call replace_operator("/", "ii", "2", "matisse_idivide");
end
end
Text: aã~
Keys pressed: `a`, `~`, `a`, `~`, space
PreviewTextInputStart: a
TextInputStart: a
PreviewTextInput: a
TextInput: a
PreviewTextInputStart: ~
TextInputStart: ~
PreviewTextInputUpdate: ã
Text: aã~
Keys pressed: `a`, `~`, `a`, `~`, space
PreviewTextInputStart: a
TextInputStart: a
PreviewTextInput: a
PreviewTextInputStart: ~
TextInputStart: ~
PreviewTextInputUpdate: ã
TextInputUpdate: ã
package helloworld
import scala.collection.immutable.LinearSeq
import scala.annotation.tailrec
import scala.util.Random
import scala.collection.mutable.MutableList
import scala.collection.immutable.Queue
object HelloWorld {
Tanto a resposta do Gabriel Santos como a do mgibsonbr estão erradas (embora funcionem bem nalguns casos limitados que acabam por ser os mais comuns).
**Porque motivo estão errados?**
Unicode. Nos tempos ancestrais (ASCII), cada caracter ocupava um espaço constante, mas isso já não é verdade.
O JavaScript usa o sistema UTF-16, em que aquilo a que a maioria das pessoas associa a caracter é dividido em "code points", que por sua vez são divididos em "code units".
Um caracter pode ter um ou mais code point e cada code point pode ter um ou dois code units. O primeiro é o code point "principal" e os seguintes (opcionais) são modificadores que acrescentam algo ao caracter (exemplo: acentos).
Quando um code point ocupa dois code units em UTF-16, diz-se que o primeiro é o "High Surrogate" (ou lead surrogate) e o segundo é o "Low Surrogate" (ou trail surrogate).
class ObservableDataPropertyAttribute : Attribute
{
}
class DependsOnAttribute : Attribute
{
public string Dependency { get; private set; }
public DependsOnAttribute(string dependency)
{
@luiscubal
luiscubal / Person.cs
Created November 30, 2013 17:37
Simple Person class (with and without INotifyPropertyChanged)
//Without events
class Person {
public string Name { get; set; }
}
//With events
class Person : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
string name;
Starting new resolver for foo.ContinueWith (precedent => {
Console.WriteLine (precedent.IsFaulted);
})
ResolveResult is [CSharpInvocationResolveResult [Method System.Threading.Tasks.Task.ContinueWith(continuationAction:System.Action`2[[System.Threading.Tasks.Task],[System.Object]], state:System.Object):System.Threading.Tasks.Task]]