View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Lalit Kapoor

Writing Code
fib: num
  (num=1) 
    ifTrue: [^ 1].
  (num=0) 
    ifTrue: [^ 1].
  (num<0)
    ifTrue: [self error: 'Fibonnaci Sequence Does Not Go Below 0'].

  ^ (self fib: (num-1)) + (self fib: (num-2)).


Tracing Code
| data onlyPositiveNumbers |
data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).
onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].
data := data select: onlyPositiveNumbers.
data := data copyUpTo: 999. "not including"
Transcript show: data average

These are our instance variables that we are going to use.
| data onlyPositiveNumbers |

the data variable is given the values: 1 2 3 -4 -5 'error' 6 -7 999 2 and is initalized to a new OrderedCollection.
data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).

onlyPositiveNumbers is a codeblock set to equal all the positive numbers in an object, it will return the type Number with only the positive numbers.
onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].

the variable data is set to equal only the positive numbers from it's original OrderedCollection.
data := data select: onlyPositiveNumbers.

data is set to equal all the values up to 999, which in this case means (1 2 3 6)
data := data copyUpTo: 999. "not including"

This line prints the average of data to the console (the average in this case is: 3.
Transcript show: data average


Finding tools: How do you use implementors of..., senders of..., and the method finder to find where code can be found in the system?

Method Finder

The Method Finder is a tool built into the squeak VM, it helps a developer to find existing methods in their image of squeak.
There are two ways to use the method finder: keywords and by example.

keyword: The keyword search technique is used to look up methods that match a certain keyword.
by example: The by example technique is used to look up methods based on what will be inputed and what the expected output is.

How to use the Method Finder for a keyword search:

How to use the Method Finder for an example search:

Implementors of..
Implementors of will show you which methods respond to a message sent by the current method. It can also show you different uses of the current method.

How to use Implementors of

Senders of..
Senders of will show the developer which methods can call the method that you are currently on.

How to use Senders of

Method finder
Uploaded Image: method.png

Implementors of.. Senders of..
Uploaded Image: is.png

lalit kapoor
http://www.lalitkapoor.com
http://lalitkapoor.com
http://www.idefine.net
http://www.schizzlenet
http://idefine.net

check out this cool site:
http://www.sqlconverter.com

lalitkapoor
lalit kapoor
idefine

excel to mysql

Link to this Page