|
|
|
|
|
by kyllo
4269 days ago
|
|
How about if you are implementing a library for a new programming language? Don't PL developers need to implement things like List.reverse() in their new languages all the time? Rhetorical question, because I know the answer is yes. Here's an example for Julia: https://github.com/JuliaLang/DataStructures.jl/blob/master/s... function reverse{T}(l::LinkedList{T})
l2 = nil(T)
for h in l
l2 = cons(h, l2)
end
l2
end
(Note that this algorithm is not an in-place reversal, so it wouldn't have worked for the OP's interview.) |
|
The premise of your remark indicates the absurdity of the claim of relevance. An interview for a position responsible for writing a new language in a language sufficiently low level to require a new `list.reverse` would invariably require implementation of a list type as well...what language includes <List> without a reverse?