new tasks

This commit is contained in:
Ingy döt Net 2013-04-09 00:46:50 -07:00
parent 2a4d27cea0
commit 80737d5a6a
1194 changed files with 15353 additions and 1 deletions

View file

@ -0,0 +1,12 @@
|array|
"creates an array that holds up to 20 elements"
array := Array new: 20 .
"access the first element: array base is 1"
(array at: 1) displayNl.
"put 100 as second value; you can put any object,
in particular SmallInteger"
array at: 2 put: 100.
"initialize an array from a 'constant' given array"
array := Array withAll: #('an' 'apple' 'a' 'day' 'keeps' 'the' 'doctor' 'away').
"Replacing apple with orange"
array at: 2 put: 'orange'.

View file

@ -0,0 +1,7 @@
"assigning values to an array"
"suppose array is bound to an array of 20 values"
array at: 5 put: 'substitute fifth element'.
[ array at: 21 put: 'error' ]
on: SystemExceptions.IndexOutOfRange
do: [ :sig | 'Out of range!' displayNl ].

View file

@ -0,0 +1,2 @@
"retrieving a value from an array"
#($a $b $c) at: 2

View file

@ -0,0 +1,3 @@
array do:[:each | each printOn: aStream ]
array collect:[:each | each squared|
array select:[:each | each > 10]

View file

@ -0,0 +1 @@
{ Time now . 10 . Date today . 'foo' }

View file

@ -0,0 +1,12 @@
oc := OrderedCollection withAll: #(4 5 6).
oc add:1. oc add:2. oc add:3.
foo := oc removeFirst.
oc addFirst:10.
oc removeLast.
oc at:2 put: 'someString'.
oc add:123 beforeIndex:10.
oc asArray printCR.
oc2 := oc copyFrom:5 to:10
oc indexOf: 'someString'
oc findFirst:[:el | el isString]
"hundreds of other methods skipped here.."

View file

@ -0,0 +1 @@
#(1 2 3 'four' 5.0 true false nil (10 20) $a)