PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/tcl/std_vector/runme.tcl

#
TCL | 40 lines | 26 code | 10 blank | 4 comment | 0 complexity | a5d000b07f404d198567e5795bd36006 MD5 | raw file
 1# file: runme.tcl
 2
 3catch { load ./example[info sharedlibextension] example}
 4
 5# Exercise IntVector
 6
 7set iv [IntVector]
 8$iv push 1
 9$iv push 3
10$iv push 5
11
12puts "IntVector size:      [$iv size]   (should be 3)"
13puts "IntVector average:   [average $iv] (should be 3.0)"
14puts "IntVector pop:       [$iv pop]   (should be 5)"
15puts "IntVector pop:       [$iv pop]   (should be 3)"
16puts "IntVector get 0:     [$iv get 0]   (should be 1)"
17puts ""
18
19# Exercise DoubleVector
20
21set dv [DoubleVector]
22$dv push 2 
23$dv push 4
24$dv push 6
25 
26puts "DoubleVector size:   [$dv size]           (should be 3)"
27puts "DoubleVector data:   [$dv get 0] [$dv get 1] [$dv get 2] (should be 2.0 4.0 6.0)"
28halve_in_place $dv
29puts "DoubleVector halved: [$dv get 0] [$dv get 1] [$dv get 2] (should be 1.0 2.0 3.0)"
30puts ""
31
32# Complain if unknown is called
33rename unknown unknown_orig
34proc unknown {args} {
35  puts "ERROR: unknown called with: $args"
36  uplevel 1 unknown_orig $args
37}
38
39puts "average \"1 2 3\": [average [list 1 2 3]]"
40