小编Ale*_*x D的帖子

Julia 中的链表

任何人都可以帮助我理解接下来的事情:
1)为什么我们需要在创建链表的同时创建一个未来结构的新抽象类?
2) 为什么有一个参数 T?
3)这个操作符是做什么的<:(书上没找到)?
4) 我们可以用下面的方式来代替 Example 吗?:

type LinkedList 
    name = Ptr{Uint8}
    next :: LinkedList
end
Run Code Online (Sandbox Code Playgroud)

例子:

abstract type LinkedList{T} end

mutable struct Nil{T} <: LinkedList{T}
end

mutable struct Cons{T} <: LinkedList{T}
   head::T
   tail::LinkedList{T}
end
Run Code Online (Sandbox Code Playgroud)

谢谢!

julia

1
推荐指数
1
解决办法
1894
查看次数

标签 统计

julia ×1