Agda Vec.filter 给出了一个 Vec≤,我如何返回一个 Vec?
Agda Vec.filter gives a Vec≤, how do I go back to a Vec?
我注意到 Vec.filter
的签名是
filter : ∀ {n} → Vec A n → Vec≤ A n
为了回到Vec
,我只能使用
吗
padRight : ∀ {n} → A → Vec≤ A n → Vec A n
或
padLeft : ∀ {n} → A → Vec≤ A n → Vec A n
?
理想情况下,我想取回一个 Vec
,其长度等于 Vec
的初始长度减去已过滤掉的元素数(而不是填充点其中元素已被过滤掉)。
谢谢!
如果您查看 the definition of Vec≤
,您会发现它已经正是您所要求的:
record Vec≤ (A : Set a) (n : ℕ) : Set a where
constructor _,_
field {length} : ℕ
vec : Vec A length
.bound : length ≤ n
所以 Vec≤ A n
的 vec
是“正常” Vec A length
,对于一些 length
小于 n
。
我注意到 Vec.filter
的签名是
filter : ∀ {n} → Vec A n → Vec≤ A n
为了回到Vec
,我只能使用
padRight : ∀ {n} → A → Vec≤ A n → Vec A n
或
padLeft : ∀ {n} → A → Vec≤ A n → Vec A n
?
理想情况下,我想取回一个 Vec
,其长度等于 Vec
的初始长度减去已过滤掉的元素数(而不是填充点其中元素已被过滤掉)。
谢谢!
如果您查看 the definition of Vec≤
,您会发现它已经正是您所要求的:
record Vec≤ (A : Set a) (n : ℕ) : Set a where
constructor _,_
field {length} : ℕ
vec : Vec A length
.bound : length ≤ n
所以 Vec≤ A n
的 vec
是“正常” Vec A length
,对于一些 length
小于 n
。