Hello! I wrote little function but its not show output. I am fresh in this language and I’ve no idea why it’s not work.
My input is : f(x->1) after that program freezes.
This is function:
The parameters of f seem a little odd to me, what f(func=x^2) should mean? It seems to mean that func is the sole parameter and it can be ommited, in this case, the value is the square of a global variable x?
Welcome to the Julia forum! There are several problems with your code:
the function is missing an end (please indent properly, that should help you catch those things)
the func default argument x^2 is not a function, but a value (if x is in scope), perhaps you meant x -> x^2 (which is, BTW, available as abs2 in Julia)
finally, for x -> 1, neither branch is called (1 < 1 is always false), so no values are changed. You can print things in a loop (see @show), or use the debugger. It may be better to just use an else anyway.