Arc Forumnew | comments | leaders | submitlogin
1 point by sacado 6153 days ago | link | parent

Oh, sorry. I guess it has to be added then :)


3 points by sacado 6153 days ago | link

Do you think it is the right thing ? If so, I'll push it to the git. Nothing amazing there, just mzscheme vectors that can be called as hash tables, lists or string. It's got a constructor (vec) and responds to len. Any further function can (should) be written in Arc.

  arc> (= v (vec 10))
  #10(nil)
  arc> (= (v 1) 0)
  0
  arc> (len v)
  10
  arc> (v 0)
  nil
  arc> (v 1)
  0
  arc> (v 10)
  Error: "vector-ref: index 10 out of range [0, 9] for vector: #10(nil 0 nil)"

-----

2 points by almkglor 6153 days ago | link

Looks good. I vote for "push".

Edit: Although it might (?) be better in the lib/array.arc, unless of course it's already integrated into ac.scm...

Edit2: Also, I hope (vec ...) is a function, not a macro or special form, so that existing code that uses vec as a local variable for a collection, or as a function, can still work.

-----

2 points by sacado 6153 days ago | link

It can't be put in a .arc file, since it is pure scheme code. Further functions dealing with vectors should go in lib/array.arc, however. And yes, vec is a function.

-----

2 points by Jekyll 6153 days ago | link

That's awesome, but I've just lost all my motivation to learn git.

Nice work :D.

-----

1 point by sacado 6152 days ago | link

It is still very basic. Many utilitary functions could be added on top of that if you want :)

-----

1 point by sacado 6153 days ago | link

pushed. type on a vector also returns 'vec.

-----