comparison src/solver.tp @ 32:2b5357b13e2d

Initial work on solver
author Mike Pavone <pavone@retrodev.com>
date Sat, 10 Aug 2013 19:54:20 -0700
parents
children b00904b36aca
comparison
equal deleted inserted replaced
29:3690601c8c70 32:2b5357b13e2d
1 #{
2 classify <- :prog trees {
3 testvals <- #[]
4 i <- 0
5 (os srand: (os time))
6 while: {i < 256} do: {
7 i <- i + 1
8 testvals append: (uint64: (os rand64))
9 }
10 root <- dict linear
11 foreach: trees :idx tree {
12 prog root!: tree
13 res <- prog run: (testvals get: 0)
14 arr <- root get: res withDefault: #[]
15 arr append: tree
16 if: (arr length) = 1 {
17 root set: res arr
18 }
19 }
20 #{
21 inputs <- { testvals }
22 valmap <- { root }
23 }
24 }
25
26 main <- :args {
27 size <- 3
28 if: (args length) > 1 {
29 size <- int32: (args get: 1)
30 }
31 prog <- bv program
32 if: size >= 2 {
33 trees <- (prog allOfSize: size)
34 if: (args length) > 2 {
35 ops <- (args get: 2) splitOn: ","
36 trees <- prog filterTrees: trees ops
37 }
38 info <- classify: prog trees
39 foreach: (info valmap) :val arr {
40 print: "Value: 0x" . (hex: val) ." produced by " . (string: (arr length)) . "programs\n"
41 }
42 }
43 }
44 }