sudo apt-get install ttf-mscorefonts-installer
P.S. Don't forget to restart you browser afterwards.
sudo apt-get install ttf-mscorefonts-installer
A = [ 1, 2, 3; 4, 5, 6 ];
submat(A,2:3) % same as A(:,2:3)
-> [ 2, 3; 5, 6 ]
B = { 'Hello', 'submat'; 'Goodbye', '(:)' };
submat(B',1) % same as B'{:,1}
-> { 'Hello', 'submat' }
grouped( [ 1, 2, 1, 3, 1, 2, 3] )
-> { [ 1, 3, 5 ], [ 2, 6 ], [ 4, 7 ] }
%artists = { 'Beatles', 'Bob Dylan' };
%records
record_artist_ids = [1, 1, 2, 2, 1];
% or the result of group(record_artist_ids)
record_artist_ids = { [1, 2, 5], [3, 4] };
title = { 'White Album', 'Rubber Soul', 'Blood on the Tracks', 'Blonde on Blonde', 'Revolver' };
year = [ 1968, 1965, 1975, 1966, 1966 ];
artist_records = grouped ( record_artist_ids, 'title', title, 'year', year)
-> artist_records(1).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(1).year = [ 1968, 1965, 1966 ]
artist_records(2).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(2).year = [ 1975, 1966 ]
value:Type
is always displayed correctly, but it seemed to work with the samples.)trait ->| Adder ->| def ->| add ->| Int ->| 2 ->| left ->| Int ->| right ->| Int
/**
* Adder
*/
trait Adder
{
def add ( left : Int, right : Int ) : Int
}
without pressing two keys at the same time (no SHIFT)!Stream
s. Their laziness allows really nice implementations of incremental algorithms and tail-recursive functions. the best thing is they can be used efficiently under different requirements: no matter if you are interested in each intermediate result or only the final one, you'll only need one implementations. =)Array(1,2,3) reverse(0) = 10
.I have seen no one propose this, but I’ve been thinking for a while that it would be really helpful in situations where you have lots of optional parameters. It would be great for constructor injection, argument passing on a program interface, embedded DSLs/fluent interfaces, etc.
yield
functionality available in C# iterator blocks as of .NET 2.0 - as you might have guessed: it allows to write iterators really fast. =)Yielder
, which provides the same ease-of-use completely without pre-compilers and keyword overrides/additions. However, the implementation details were not published with it - but promised for next week (as of now 'this' week). Feeling eager how this can be done, I tried implementing the interface based on the descriptions in the text and the mentioned examples (one repeated here for convenience):
public Iterator iterator() {
return new Yielder() {
public void yieldNextCore() {
for (Object nextItem : coll) {
if (pred.evaluate(nextItem)) {
yieldReturn(nextItem);
}
}
}
};
}
Iterator
from a single Yielder
instance?yieldReturn
is a method of the Yielder
class, so it is not (automatically) aware of the a specific Iterator
instance. Therefore, I moved the method (along with a yieldBreak
equivalent) to an interface which will be passed to the iterator-block (yieldNextCore
).yieldNextCore
implies to me that the method will be called repeatedly. Probably until it exits after a yieldBreak
call or without one to yieldReturn
. Hence, in the example above it would be the number of elements the predicate pred
evaluates to true
. Taking the worst case: One call for each of the n
elements in the collection coll
. Ergo the time scale rises from O(n) to O(n^2)!yieldReturn
has be stored until the corresponding Iterator.next
call releases it. In a single threaded environment, the means all of the (predicated) elements since there is no way to suspend the for-loop. This may be practicable for iterations over a few elements. But again, the worst cast the complexity rises from O(n) to O(n^2) - this time in memory consumption!yieldNextCore
). This can block the iteration while the iterators' method can return. However, it turned out one thread is not enough, since it could "wait forever", if the iteration is not completed. Another had to monitor a weak reference to it. But again, the the problem is that the loop will always be executed, which leads to O(n) even if the iteration is not continued after retrieving the first element.
(A as B)
(Bar as Foo)
, but it looks nicer within the other syntax sugar as well:var/final
instead of specifying the reference type