This file contains 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
pub fn verse(n: i32) -> String { | |
if n > 2 { | |
format!("{0} bottles of beer on the wall, {0} bottles of beer.\nTake one down and pass it around, {1} bottles of beer on the wall.\n", n, n - 1) | |
} else if n == 2 { | |
format!("2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n") | |
} else if n == 1 { | |
format!("1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n") | |
} else { | |
format!("No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n") | |
} |
This file contains 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
// Viterbi algorithm for finding hidden relationships | |
function Viterbi(data) { | |
var V = [{}]; | |
var path = {}; | |
// Initialize base cases (t == 0) | |
for(var i=0;i<data.states.length;i++) { | |
var state = data.states[i]; | |
V[0][state] = data.start_probability[state] * data.emission_probability[state][data.observations[0]]; | |
path[state] = [state]; |
This file contains 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
;------------------------------------------------------------------------- | |
; FcAppendRgchToFn(fn, pch, cch) | |
;------------------------------------------------------------------------- | |
;/* F C A P P E N D R G C H T O F N */ | |
;/* Appends characters pointed to by pch, length cch, to end of file fn. | |
;Returns first fc written. | |
;If there is a free hole of sufficient size in vfkpdText, it will be | |
;used instead. | |
;fcLim updated to point to after the last char written. | |
;*/ |
This file contains 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
The programmer bryanl left some real nice comments in the source code. I bet he never expected it to be looked at years later. I've added some commentary myself too. | |
Line 412: | |
When a character is typed, it is inserted at rgchInsert[ichInsert++]. | |
When rgchInsert is full, it is written to the scratch file, and Replace'd | |
with a new insertion block. | |
Line 222: | |
fc = FcAppendRgchToFn(fnScratch, rgchInsert, ichInsert); |
This file contains 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
# Applies a change to the buffer based on its old range and new text. | |
applyChange: (change) -> | |
{newStart, oldExtent, newExtent, oldText, newText, normalizeLineEndings} = change | |
start = Point.fromObject(newStart) | |
oldRange = Range(start, start.traverse(oldExtent)) | |
newRange = Range(start, start.traverse(newExtent)) | |
oldRange.freeze() | |
newRange.freeze() | |
@cachedText = null |
This file contains 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
;; Calculate the location of Sprite 1 | |
ld hl, wOAMAddr | |
ld de, wOAM | |
ld [hl], d | |
inc hl | |
ld [hl], e | |
mUpdateSprite 80, 40, $59, 0, 2, 3 |
This file contains 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
loop: | |
call WaitVBlank | |
mUpdateSprite 0, 100, 80, $59, 0, 2, 3 | |
call _HRAM | |
jp loop |
This file contains 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
INCLUDE "Global.inc" | |
; Cartridge header | |
SECTION "Org $00",ROM0[$00] | |
RST_00: | |
jp $100 | |
SECTION "Org $08",ROM0[$08] | |
RST_08: |
This file contains 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
INCLUDE "Global.inc" | |
; Cartridge header | |
SECTION "Org $00",HOME[$00] | |
RST_00: | |
jp $100 | |
SECTION "Org $08",HOME[$08] | |
RST_08: |
This file contains 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
Hey, this is a long shot, but here goes. | |
I have this defined in my .vtwmrc configuration file: | |
Function "map-show" { f.showdesktopdisplay f.warpto "VTWM Desktop" } | |
Function "iconmgr-show" { f.showiconmgr f.warpto "VTWM Icon Manager" } | |
called with: | |
"Space" = control : all : f.function "map-show" | |
"Space" = shift : all : f.function "iconmgr-show" |