25 lines
767 B
Plaintext
25 lines
767 B
Plaintext
include "NSLog.incl"
|
|
|
|
local fn IdentityMatrix( n as NSInteger ) as CFStringRef
|
|
NSInteger i, j
|
|
CFMutableArrayRef tempArr = fn MutableArrayWithCapacity( n )
|
|
CFMutableStringRef mutStr = fn MutableStringWithCapacity( 0 )
|
|
|
|
for i = 0 to n - 1
|
|
MutableArrayRemoveAllObjects( tempArr )
|
|
for j = 0 to n - 1
|
|
MutableArrayInsertObjectAtIndex( tempArr, @"0", j )
|
|
next
|
|
MutableArrayReplaceObjectAtIndex( tempArr, @"1", i )
|
|
MutableStringAppendString( mutStr, fn ArrayComponentsJoinedByString( tempArr, @" " ) )
|
|
MutableStringAppendString( mutStr, @"\n" )
|
|
next
|
|
end fn = fn StringWithString( mutStr )
|
|
|
|
NSLog( @"3:\n%@", fn IdentityMatrix( 3 ) )
|
|
NSLog( @"5:\n%@", fn IdentityMatrix( 5 ) )
|
|
NSLog( @"7:\n%@", fn IdentityMatrix( 7 ) )
|
|
NSLog( @"9:\n%@", fn IdentityMatrix( 9 ) )
|
|
|
|
HandleEvents
|