Last active
June 9, 2018 10:32
-
-
Save mafintosh/0ad0649ae768fb48ae93877fcb37c491 to your computer and use it in GitHub Desktop.
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
(module | |
(memory (export "memory") 10 10000) | |
(func (export "index_of") (param $start i32) (param $end i32) (param $needle i32) (result i32) | |
(block $end_loop | |
(br_if $end_loop (i32.eq (get_local $start) (get_local $end))) | |
(if (i32.eq (i32.load8_u (get_local $start)) (get_local $needle)) | |
(then (return (get_local $start))) | |
) | |
(set_local $start (i32.add (i32.const 1) (get_local $start))) | |
) | |
(i32.const -1) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment