Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/rosetta/exercises/secret-handshake/.meta/example.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / secret-handshake / .meta / example.om` 49 lines ยท 1043 bytes Raw Blame History 1 note Exercism-style exercise "secret-handshake": https://exercism.org/tracks/python/exercises/secret-handshake 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 note commands writes the handshake of the low five bits of n into o, joined by commas: 1 wink, 4 note 2 double blink, 4 close your eyes, 8 jump, in that order, reversed when bit 16 is set; returns 5 note the number of bytes written. 6 note Check it with: sh exercise.sh exercises/secret-handshake 7 om2 8 text hs0 "wink" 9 text hs1 "double blink" 10 text hs2 "close your eyes" 11 text hs3 "jump" 12 fn app o edit uchar * p ulong s view uchar * to ulong 13 q = p 14 for i ulong len s 15 put o q get s i 16 q = add q 1 17 end 18 ret q 19 end 20 fn appcmd o edit uchar * p ulong k ulong to ulong 21 if eq k 0 22 ret app o p hs0 23 end 24 if eq k 1 25 ret app o p hs1 26 end 27 if eq k 2 28 ret app o p hs2 29 end 30 ret app o p hs3 31 end 32 fn commands n ulong o edit uchar * to ulong 33 p = ulong 0 34 rev = ne and n 16 0 35 for i ulong 4 36 k = i 37 if rev 38 k = sub 3 i 39 end 40 if ne and shr n k 1 0 41 if gt p 0 42 put o p 44 43 p = add p 1 44 end 45 p = appcmd o p k 46 end 47 end 48 ret p 49 end