Created
May 20, 2021 09:47
-
-
Save cuongld2/b346a8e7acd816a7c6dfd6ad39286ad1 to your computer and use it in GitHub Desktop.
get length of array in julia using recursive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_length(array) | |
if array==[] | |
return 0 | |
end | |
deleteat!(array, last(array)) | |
return 1 + get_length(array) | |
end | |
println(get_length([1,2,3,4])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment