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
omega-mv / train / omega-llm / tools / contrast / select.om
| 1 | note select EXAMPLE_PANEL OMC FIRST_DIR SECOND_DIR THIRD_DIR [compile]. Each directory contains answer-N. |
| 2 | note Use a fresh working directory. Selected function bodies are written as answer-N for independent grading. |
| 3 | text slash "/" |
| 4 | text compilearg "compile" |
| 5 | fn copyanswer a ulong j ulong to void |
| 6 | wdpclr |
| 7 | wdpa a |
| 8 | wdpt slash |
| 9 | wdpt outname |
| 10 | wdpd j |
| 11 | fi = wdopen 0 0 |
| 12 | if lt fi 0 |
| 13 | exit 74 |
| 14 | end |
| 15 | pathfor j |
| 16 | fo = wdopen 577 384 |
| 17 | if lt fo 0 |
| 18 | exit 74 |
| 19 | end |
| 20 | wdcopyfd fi fo |
| 21 | ca = fclose fi |
| 22 | cb = fclose fo |
| 23 | end |
| 24 | fn choose src view uchar 262144 tape view uint 262144 obj ulong j ulong to ulong |
| 25 | for k ulong 3 |
| 26 | copyanswer add k 3 j |
| 27 | grade = testrow src tape obj j |
| 28 | if or eq grade 2 and eq argcnt 7 eq grade 1 |
| 29 | ret add k 1 |
| 30 | end |
| 31 | end |
| 32 | pathfor j |
| 33 | empty = wdopen 577 384 |
| 34 | if lt empty 0 |
| 35 | exit 74 |
| 36 | end |
| 37 | cl = fclose empty |
| 38 | ret 0 |
| 39 | end |
| 40 | fn main to int |
| 41 | if and ne argcnt 6 ne argcnt 7 |
| 42 | ret 2 |
| 43 | end |
| 44 | if eq argcnt 7 |
| 45 | if not argis 6 compilearg |
| 46 | ret 2 |
| 47 | end |
| 48 | end |
| 49 | src = new uchar 262144 0 |
| 50 | tape = new uint 262144 0 |
| 51 | wdpclr |
| 52 | wdpa 1 |
| 53 | fd = wdopen 0 0 |
| 54 | if lt fd 0 |
| 55 | ret 70 |
| 56 | end |
| 57 | n = read fd src 0 len src |
| 58 | cl = fclose fd |
| 59 | if or lt n 1 eq n long len src |
| 60 | ret 72 |
| 61 | end |
| 62 | if lt js_init tape 262144 128 0 |
| 63 | ret 72 |
| 64 | end |
| 65 | if lt js_parse src tape ulong n 0 |
| 66 | ret 72 |
| 67 | end |
| 68 | if ne js_type tape 0 jsarr |
| 69 | ret 72 |
| 70 | end |
| 71 | obj = js_first tape 0 |
| 72 | j = ulong 0 |
| 73 | while ne obj jsnone bound 4294967295 |
| 74 | chosen = choose src tape obj j |
| 75 | wdod j |
| 76 | wdot sep |
| 77 | wdod chosen |
| 78 | wdot lf |
| 79 | wdoflush 1 |
| 80 | j = add j 1 |
| 81 | obj = js_enext tape obj |
| 82 | end |
| 83 | if eq j 0 |
| 84 | ret 72 |
| 85 | end |
| 86 | ret 0 |
| 87 | end |