Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write own defined function that includes an imported function?

I am learning Julia programming by reading the book Think Julia I am including the following:

enter image description here

forward is a function in the ThinkJulia module. It acts on the Turtle() object, to move it forward. Why, after the line using ThinkJulia , am I getting this error. Do I have to be more specific in Julia about importing functions? I thought using would give me access to all functions in that particular module?

like image 294
lhoernle Avatar asked Aug 11 '26 10:08

lhoernle


1 Answers

You need to pass a value not to its type to forward, so define your function like this:

function forward_len(t::Turtle, d)
    forward(t, d)
end

and things should work

like image 166
Bogumił Kamiński Avatar answered Aug 13 '26 01:08

Bogumił Kamiński