Welcome to Dream.In.Code
Become an Expert!

Join 137,425 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,930 people online right now. Registration is fast and FREE... Join Now!




tcl

 
Reply to this topicStart new topic

tcl, can sombody help me about tcl programming language

senyorita
15 Jan, 2008 - 08:54 AM
Post #1

New D.I.C Head
*

Joined: 5 Sep, 2007
Posts: 9


My Contributions
what wrong with my program below...
CODE

set size 5;

proc mkmatrix {rows cols} {
    set count 1;
    set mx [list]
      for { set i 0 } { $i < $rows } { incr i } {
    set row [list]
    for { set j 0 } { $j < $cols } { incr j } {
       lappend row $count;
       incr count;
       }
         lappend mx $row;
     }
      return $mx;
}

    proc mmult {m1 m2} {
         set cols [lindex $m2 0]
           foreach row1 $m1 {
              set row [list]
            set i 0
            foreach - $cols {
               set elem 0
                foreach elem1 $row1 row2 $m2 {
                  set elem [expr {$elem + $elem1 * [lindex $row2 $i]}]
                }
                lappend row $elem
                  incr i
               }
              lappend result $row
       }
       return $result
}

proc main {} {
      global argv size
      set num [lindex $argv 0]
       if {$num < 1} {
      set num 1
      }

      set m1 [mkmatrix $size $size]
      set m2 [mkmatrix $size $size]
      while {$num > 0} {
          incr num -1
          set m [mmult $m1 $m2]
      }

      puts "[lindex [lindex $m 0] 0] [lindex [lindex $m 2] 3] [lindex [lindex $m 3] 2] [lindex [lindex $m 4] 4]"
}

main


[Admin Edit: Added [code] tags]
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Tcl
15 Jan, 2008 - 08:58 AM
Post #2

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,974



Thanked: 48 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
In the future please post your code like this: code.gif

What is your program doing or not doing that it shouldn't be? Any errors? Help us help you.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/5/08 04:43AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month