variable namespace, function declaration fixes

This commit is contained in:
ProgramSnail 2023-04-29 12:33:05 +03:00
parent c31b20fa24
commit f973f65b5b
17 changed files with 511 additions and 98 deletions

View file

@ -16,7 +16,7 @@ def fact : n =
| _ -> error "n must be positive"
decl find_prefix_hashes ('H : (#AccHash Char)) : String -> (Array 'H)
def find_prefix_hashes 'H : str = {
def find_prefix_hashes : str = {
var hashes = (Array 'H).new (str.size () + 1)
; hashes:0 = 'H.of str:0
@ -38,7 +38,7 @@ def find_substring : str substr = {
const substr_hash = Hash.of substr
for i in 0..(str_hashes.size () - substr.size ()) do {
const part_hash = Hash.diff str_hashes:(i + substr->size ()) str_hashes:i
const part_hash = Hash.diff str_hashes(i + substr->size ()) str_hashes:i
if part_hash == substr_hash then {
; result.push i