Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 2 additions & 26 deletions specs/t27mcp/examples.t27
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

module T27mcpExamples;

use t27mcp::check_hints;

/// The commit of gHashTag/t27 every row points into.
pub const PIN : str = "a18d7ee14a9994ef9dc84dac10e1a2944367d4c5";

Expand All @@ -47,7 +49,6 @@ pub const TOPICS : [8]str = [
];

pub const NO_ROW : u32 = 4294967295;
pub const NO_POS : u32 = 4294967295;
pub const MAX_LINES : u32 = 40;
pub const ROWS : u32 = 10;

Expand Down Expand Up @@ -82,31 +83,6 @@ pub const EX_WHY : [10]str = [
"The header states that nothing here is reset: the counters start from their var initialisers."
];

/// Byte offset of the first occurrence of `needle` in `hay`, or NO_POS.
pub fn find(hay: string, needle: string) -> u32 {
var hn : u32 = (hay.len as u32);
var nn : u32 = (needle.len as u32);
if (nn > hn) { return NO_POS; }
var i : u32 = 0;
while (i <= hn - nn) {
var j : u32 = 0;
var same : u32 = 1;
while (j < nn) {
if ((hay[i + j] as u32) != (needle[j] as u32)) { same = 0; }
j = j + 1;
}
if (same == 1) { return i; }
i = i + 1;
}
return NO_POS;
}

/// 1 when `needle` occurs in `hay`.
pub fn has(hay: string, needle: string) -> u32 {
if (find(hay, needle) == NO_POS) { return 0; }
return 1;
}

/// The topic a lower-case question is about, or T_NONE.
pub fn topic_code(q: string) -> u32 {
if (has(q, "reset") == 1) {
Expand Down
Loading