Initial Commit

This commit is contained in:
MarcusTL12
2019-09-12 16:32:16 +02:00
parent 3eff6439e4
commit 4adc9cd975
20 changed files with 1151 additions and 0 deletions

21
Code/17.Broadcast.jl Normal file
View File

@@ -0,0 +1,21 @@
# The broadcast operator (.) can be quite useful when dealing with arrays.
# Basically whenever an operator or function is used, you can just write
# a dot (.) before the operator/function to make it act elementwise.
# Here we elementwise add 3 to the array
a = [1, 2, 3, 4]
a .+= 3
@show a
# Here we elementwise multiply a by 2 and then elementwise add a and b.
b = a .* 2
@show b
c = a .+ b
@show c
# To elementwise use more general functions the dot symbol is placed between
# the function name and parentheses.
f(x) = 2x^2
d = f.(c)
@show d