3 new blocks!
Note: I saw a suggestion for this in the Suggestions forum and decided to make it. While at first it might seem like it just does the following:
When Green Flag Clicked
forever {
point towards [ v].
move ( ) steps. }
The advantage of this is that this doesn't affect direction, allowing you to use direction for something else.
('move %n steps towards %m' #- #Move:Towards:)
Move: t1 Towards: t2 | t3 t4 t5 t6 t7 t8 t9 | t2 = #mouse ifFalse: [t3 _ t2 xpos @ t2 ypos - self referencePosition]. t2 = #mouse ifTrue: [t3 _ self mouseX rounded @ self mouseY - self referencePosition]. t4 _ t3 x abs < 0.001 ifTrue: [t3 y < 0 ifTrue: [90] ifFalse: [270]] ifFalse: [((t3 x >= 0 ifTrue: [0] ifFalse: [180]) - ((t3 y / t3 x) arcTan * 57.2957795131)) rounded]. t5 _ t4 degreesToRadians. t6 _ t5 cos @ t5 sin * t1. t7 _ self position + t6. t8 _ t7 x. t9 _ t7 y. t8 isNaN ifTrue: [t8 _ 0]. t8 isInf ifTrue: [t8 _ t8 sign * 10000]. t9 isNaN ifTrue: [t9 _ 0]. t9 isInf ifTrue: [t9 _ t9 sign * 10000]. self position: t8 @ t9. self keepOnScreen
***Credit note: Improved by Baderous.***
('font %s exists?' #b #FontExists:)
FontExists: t1 | t2 | t2 _ UnicodePlugin getFontList collect: [:f | f asUTF8]. ^ t2 includes: t1
***Credit note: Improved by LS97 and Baderous.***
('import fonts to list %L' #- #FontstoList: 'list')
Method code:
FontstoList: t1 | t2 | t2 _ UnicodePlugin getFontList. t2 do: [:t3 | self append: t3 toList: t1]
Scratch-Objects > Scriptable Scratch Morph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#FontstoList: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
Offline
4 more blocks:
('sum of items of %L' #r #SumOf: 'list')
Method code:
SumOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a + (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ a
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:
#SumOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('difference of items of %L' #r #DiffOf: 'list')
Method code:
DiffOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a - (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ a
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:
#DiffOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('product of items of %L' #r #ProdOf: 'list')
Method code:
ProdOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a * (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ a
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:
#ProdOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('quotient of items of %L' #r #QuotOf: 'list')
Method code:
QuotOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a / (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ a
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:
#QuotOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
Last edited by Greenatic (2011-07-30 17:14:59)
Offline
('font #%n' #r #FontNumber:)
FontNumber: t1 | t2 t3 | t1 isInf ifTrue: [^ nil]. t1 isNaN ifTrue: [^ nil]. t1 = t1 rounded ifFalse: [^ nil]. t1 < 1 ifTrue: [^ nil]. t2 _ UnicodePlugin getFontList. t2 size < t1 ifTrue: [^ nil]. t3 _ 1. t2 do: [:t4 | t3 = t1 ifTrue: [^ t4]. t3 _ t3 + 1]
@WhoeverDoesTheNextUpdate: I pity you. XD
Offline
I noticed You had no explanation of "Instance" in the glossary. An instance is basically an object made from a class, but not the object itself. a little confusing
Offline
The Show and hide cursor blocks don't work. I checked and the blockspec and Code are correctly copied. When the program gets to the block, If fill screen is turned off, it says: Message not Understood: showCursor/hideCursor. Can anyone help???
Last edited by Skalled (2011-07-30 22:57:03)
Offline
Greenatic wrote:
@WhoeverDoesTheNextUpdate: I pity you. XD
Well, I'll have to grab a few hours across a few days! XD
Or... hint, hint. (Librarians, what were you hired for?)
hello12345678910 wrote:
I noticed You had no explanation of "Instance" in the glossary. An instance is basically an object made from a class, but not the object itself. a little confusing
Instance: An object made from a class, but not the object itself.
Offline
This is a text for my phanter aplication.
Offline
Made this block:
Here are the scripts:
Simple.
Last edited by Mcsugarface (2011-07-31 22:42:27)
Offline
ssss wrote:
I reckon you should hire me as a librarian.
As I am online when almost no-one is, I can update the blocks and stuff, and save you guys some effort!
Maybe you can hire us both?
Last edited by scratcher7_13 (2011-08-01 03:56:31)
Offline
Sidharth wrote:
I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif
.ysp file is here. (mediafire download link page)
that is on the byob tool sprite. It is called (sentance -> list [ ])
Offline
The 'most recent update' links the wrong post.
Offline
joefarebrother wrote:
Sidharth wrote:
I have a nice BYOB block that I think you do not already have:
http://i.imgur.com/FpG60.gif
.ysp file is here. (mediafire download link page)that is on the byob tool sprite. It is called (sentance -> list [ ])
lol I think every block is in the tool sprite... I made that one by myself BTW. I have another one that can use a delimeter such as a comma or hyphen.
Offline
The first post is all messed up. At least for me, it is.
Offline
So many new blocks! (Sorry, Scimonster XD )
('add items %n to %n of %L to %L' #- #First:Last:From:To: '1' '3' 'list' 'list')
Method code:
First: t1 Last: t2 From: t3 To: t4 | t5 t6 | t1 isInf ifTrue: [^ self]. t1 isNaN ifTrue: [^ self]. t1 isNil ifTrue: [^ self]. t2 isInf ifTrue: [^ self]. t2 isNaN ifTrue: [^ self]. t2 isNil ifTrue: [^ self]. t1 = t1 rounded ifFalse: [^ self]. t2 = t2 rounded ifFalse: [^ self]. t1 < 1 ifTrue: [^ self]. t2 < 1 ifTrue: [^ self]. t1 > (self lineCountOfList: t3) ifTrue: [^ self]. t2 > (self lineCountOfList: t3) ifTrue: [^ self]. t5 _ t1. (t2 - t1) abs + 1 timesRepeat: [self append: (self getLine: t5 ofList: t3) toList: t4. t6 _ false. t2 > t1 ifTrue: [t5 _ t5 + 1. t6 _ true]. t6 = false ifTrue: [t5 _ t5 - 1]]
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#First:Last:From:To: = t4 ifTrue: [t2 size >= 4 ifTrue: [t2 at: 1 put: (t2 at: 1) localized. t2 at: 2 put: (t2 at: 2) localized. t2 at: 3 put: self defaultListName. t2 at: 4 put: self defaultListName]].
('sort items of %L by numerical value' #- #NumberSort: 'list')
Method code:
NumberSort: t1 | t2 t3 t4 t5 t6 | t2 _ #() asOrderedCollection. t3 _ #() asOrderedCollection. t4 _ #() asOrderedCollection. t6 _ #() asOrderedCollection. t5 _ 1. (self lineCountOfList: t1) timesRepeat: [t2 add: (self getLine: t5 ofList: t1). t5 _ t5 + 1]. t2 do: [:t7 | t3 add: t7 asNumberNoError. t7 asNumberNoError = 0 ifTrue: [t4 add: t7]]. t3 _ t3 asArray sort. t3 _ t3 asOrderedCollection. t5 _ 1. t3 do: [:t8 | t8 = 0 ifFalse: [t6 add: t8]. t8 = 0 ifTrue: [t6 add: (t4 at: t5). t5 _ t5 + 1]]. self deleteLine: 'all' ofList: t1. t6 do: [:t9 | self append: t9 toList: t1]
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#NumberSort: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('sort items of %L by string value' #- #StringSort: 'list')
Method code:
SringSort: t1 | t2 t3 | (self lineCountOfList: t1) = 0 ifTrue: [^ self]. (self lineCountOfList: t1) = 1 ifTrue: [^ self]. t2 _ #() asOrderedCollection. t3 _ 1. (self lineCountOfList: t1) timesRepeat: [t2 add: (self getLine: t3 ofList: t1). t3 _ t3 + 1]. t2 _ t2 asArray sort. self deleteLine: 'all' ofList: t1. t2 do: [:t4 | self append: t4 toList: t1]
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#StringSort: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('first index of %s in %L' #r #IndexOf:List: '' 'list')
Method code:
IndexOf: t1 List: t2 | t3 | t3 _ 1. (self lineCountOfList: t2) timesRepeat: [(self getLine: t3 ofList: t2) = t1 ifTrue: [^ t3]. t3 _ t3 + 1]. ^ 0
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#IndexOf:List: = t4 ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: (t2 at: 1) localized. t2 at: 2 put: self defaultListName]].
('times %s appears in %L' #r #Times:List: '' 'list')
Method code:
Times: t1 List: t2 | t3 t4 | t3 _ 1. t4 _ 0. (self lineCountOfList: t2) timesRepeat: [(self getLine: t3 ofList: t2) = t1 ifTrue: [t4 _ t4 + 1]. t3 _ t3 + 1]. ^ t4
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#Times:List: = t4 ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: (t2 at: 1) localized. t2 at: 2 put: self defaultListName]].
('maximum value of %L' #r #MaxOf: 'list')
Method code:
MaxOf: t1 | max line | (self lineCountOfList: t1) asNumberNoError = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. max _ (self getLine: 1 ofList: t1) asNumberNoError. line _ 2. (self lineCountOfList: t1) asNumberNoError - 1 timesRepeat: [(self getLine: line ofList: t1) asNumberNoError > max ifTrue: [max _ (self getLine: line ofList: t1) asNumberNoError]. line _ line + 1]. ^ max
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#MaxOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('minimum value of %L' #r #MinOf: 'list')
Method code:
MinOf: t1 | min line | (self lineCountOfList: t1) asNumberNoError = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. min _ (self getLine: 1 ofList: t1) asNumberNoError. line _ 2. (self lineCountOfList: t1) asNumberNoError - 1 timesRepeat: [(self getLine: line ofList: t1) asNumberNoError < min ifTrue: [min _ (self getLine: line ofList: t1) asNumberNoError]. line _ line + 1]. ^ min
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#MinOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
*****Note: This block requires a previously posted block, (sum of {list v} ).******
('average/mean of values of %L' #r #AverageOf: 'list')
Method code:
AverageOf: t1 (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ self getLine: 1 ofList: t1]. ^ (self SumOf: t1) / (self lineCountOfList: t1)
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#AverageOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
*****Note: This block requires the (maximum value of {list v} ) and (minimum value of {list v} ) blocks.*****
('range of values of %L' #r #RangeOf: 'list')
Method code:
RangeOf: t1 (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ 0]. ^ (self MaxOf: t1) - (self MinOf: t1)
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#RangeOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
('mode(s) of %L, spacer %s' #r #ModeOf:Spacer: 'list' ',')
Method code:
ModeOf: t1 Spacer: t2 | t3 t4 t5 t6 t7 | (self lineCountOfList: t1) = 0 ifTrue: [^ nil]. (self lineCountOfList: t1) = 1 ifTrue: [^ nil]. t3 _ #() asOrderedCollection. t4 _ #() asOrderedCollection. t5 _ 0. (self lineCountOfList: t1) timesRepeat: [t6 _ 1. t7 _ false. t5 _ t5 + 1. (t3 includes: (self getLine: t5 ofList: t1) asNumberNoError) ifFalse: [t3 add: (self getLine: t5 ofList: t1) asNumberNoError. t4 add: 1. t7 _ true]. t7 = false ifTrue: [[(t3 at: t6) = (self getLine: t5 ofList: t1) asNumberNoError] whileFalse: [t6 _ t6 + 1]. t4 _ t4 asArray. t4 at: t6 put: (t4 at: t6) + 1. t4 _ t4 asOrderedCollection]]. t5 _ 1. t6 _ 1. t4 size timesRepeat: [(t4 at: t5) > t6 ifTrue: [t6 _ t4 at: t5]. t5 _ t5 + 1]. t6 = 1 ifTrue: [^ nil]. t5 _ 1. t4 size timesRepeat: [t7 _ false. (t4 at: t5) < t6 ifTrue: [t3 removeAt: t5. t4 removeAt: t5. t7 _ true]. t7 = false ifTrue: [t5 _ t5 + 1]]. t3 size = 1 ifTrue: [^ t3 at: 1]. t5 _ 2. t3 _ t3 asArray sort. t3 _ t3 asOrderedCollection. t6 _ (t3 at: 1) asString. t3 size - 1 timesRepeat: [t6 _ t6 , t2. t6 _ t6 , (t3 at: t5) asString. t5 _ t5 + 1]. ^ t6
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#ModeOf:Spacer: = t4 ifTrue: [t2 size >= 2 ifTrue: [t2 at: 1 put: self defaultListName. t2 at: 2 put: (t2 at: 2) localized]].
('median value of %L' #r #MedianOf: 'list')
Method code:
MedianOf: t1 | t2 t3 | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. t2 _ #() asOrderedCollection. t3 _ 1. (self lineCountOfList: t1) timesRepeat: [t2 add: (self getLine: t3 ofList: t1) asNumberNoError. t3 _ t3 + 1]. t2 _ t2 asArray sort. t2 _ t2 asOrderedCollection. [t2 size > 2] whileTrue: [t2 removeAt: 1. t2 removeAt: t2 size]. t2 size = 1 ifTrue: [^ t2 at: 1]. ^ (t2 at: 1) + (t2 at: 2) / 2
Scratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Add right before the last line ( ^ t2 ):
#MedianOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
You actually read all that? Wow. You must have way too much time on your hands.
Offline
You actually read all that? Wow. You must have way too much time on your hands.
Yes, I do.
Offline
Can I be a librarian for the block library for the BYOB section? here is all the blocks i have made
Last edited by flashgocrazy (2011-08-02 18:05:41)
Offline
rookwood101 wrote:
You actually read all that? Wow. You must have way too much time on your hands.
Yes, I do.
You should read my earlier, even longer post. I think it was on the last page, maybe the page before that.
Offline
some of my blocks:
download this block
and:
download this block
also:
download this block
and:
download this block
one of my very best:
download this block
OMG!:
download this block
Requested from the block library:
download this block
NOTE: YOU NEED THE PAUSE SCRIPT BLOCK (SEE ABOVE) FOR THE BLOCK TO WORK (THE PAUSE SCRIPT BLOCK IS INCLUDED IN THE DOWNLOAD ABOVE.
Based on the panther block: {when camera open, do :}
download this block
based on the: [self] block in slash:
download this block
Last edited by flashgocrazy (2011-08-02 21:34:05)
Offline
flashgocrazy wrote:
A lot of blocks
epic!! Can you make a few more blocks?
Offline
Greenatic wrote:
4 more blocks:
http://polyeztahpuppies.webs.com/sumoflist.gifCode:
('sum of items of %L' #r #SumOf: 'list')Method code:
Code:
SumOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a + (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#SumOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/diffoflist.gif
Code:
('difference of items of %L' #r #DiffOf: 'list')Method code:
Code:
DiffOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a - (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#DiffOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/prodoflist.gif
Code:
('product of items of %L' #r #ProdOf: 'list')Method code:
Code:
ProdOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a * (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#ProdOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/quotoflist.gif
Code:
('quotient of items of %L' #r #QuotOf: 'list')Method code:
Code:
QuotOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a / (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#QuotOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].
Why not have a dropdown that you can select from either sum, difference, product, or quotient?
Offline
LiquidMetal wrote:
Greenatic wrote:
4 more blocks:
http://polyeztahpuppies.webs.com/sumoflist.gifCode:
('sum of items of %L' #r #SumOf: 'list')Method code:
Code:
SumOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a + (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#SumOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/diffoflist.gif
Code:
('difference of items of %L' #r #DiffOf: 'list')Method code:
Code:
DiffOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a - (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#DiffOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/prodoflist.gif
Code:
('product of items of %L' #r #ProdOf: 'list')Method code:
Code:
ProdOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a * (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#ProdOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].http://polyeztahpuppies.webs.com/quotoflist.gif
Code:
('quotient of items of %L' #r #QuotOf: 'list')Method code:
Code:
QuotOf: t1 | t2 a | (self lineCountOfList: t1) = 0 ifTrue: [^ 0]. (self lineCountOfList: t1) = 1 ifTrue: [^ (self getLine: 1 ofList: t1) asNumberNoError]. t2 _ 2. a _ (self getLine: 1 ofList: t1) asNumberNoError. (self lineCountOfList: t1) - 1 timesRepeat: [a _ a / (self getLine: t2 ofList: t1) asNumberNoError. t2 _ t2 + 1]. ^ aScratch-Objects > ScriptableScratchMorph > blocks > defaultArgsFor:
Right before the last line ( ^ t2 ), add:Code:
#QuotOf: = t4 ifTrue: [t2 size >= 1 ifTrue: [t2 at: 1 put: self defaultListName]].Why not have a dropdown that you can select from either sum, difference, product, or quotient?
I would say the same with mean, median and mode, as they are all types of averages.
Offline