This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,21 @@
julia> all(iseven, 1:5) # not all integers between 1 and 5 are even.
false
julia> findfirst(iseven, 1:5) # the first even integer is at index 2 in the range.
2
julia> count(iseven, 1:5) # there are two even integers between 1 and 5.
2
julia> filter(iseven, 1:5) # here are the even integers in the given range.
2-element Array{Int64,1}:
2
4
julia> map(iseven, 1:5) # we apply our function to all integers in range.
5-element Array{Bool,1}:
false
true
false
true
false

View file

@ -0,0 +1,18 @@
F1=@sin; % F1 refers to function sin()
F2=@cos; % F2 refers to function cos()
% varios ways to call the refered function
F1(pi/4)
F2(pi/4)
feval(@sin,pi/4)
feval(@cos,pi/4)
feval(F1,pi/4)
feval(F2,pi/4)
% named functions, stored as strings
feval('sin',pi/4)
feval('cos',pi/4)
F3 = 'sin';
F4 = 'cos';
feval(F3,pi/4)
feval(F4,pi/4)