glycerine/zygomys

Wiki: Generic Container needing some fix

Closed this issue · 9 comments

In the section on Generic Container Operations in the wiki/Language a few things should be fixed. The text says

The concat function can concatenate two arrays, two strings, or two lists

It would be more correct to say

The concat function can concatenate two or more arrays, two or more strings, or two lists

The examples for arrays and strings could be extended with third arguments. It's also odd that lists cannot be handled in the same way.

For the appendslice function, it is not very obvious to me what "without creating nesting" means. Also, "join to slices" should have been "join two slices".

Let me know if I shall make a PR to fix some of this.

A PR would be welcome.

OK, but can you explain what "without creating nesting" means?

compare

zygo> (appendslice [0 1] [2 3])
[0 1 2 3]
zygo> (append [0 1] [2 3])
[0 1 [2 3]]
zygo>

The append operation created a slice within an slice. I call that a nested slice.

My mistake: I guess the rest of the docs call them arrays, not slices.

To me, (appendslice [0 1] [2 3]) looks very much the same as (concat [0 1] [2 3]), except that the latter accepts more than just two arguments. What's the real difference?

Yes, they are the same. There is some overlap. append and appendslice work only with arrays (aka slices in Go). concat started as a function for strings, then was generalized to handle arrays and lists too.

A PR on a GitHub wiki seems to be not as easy as a PR on normal code. I am not sure if I shall go ahead on this. Some info on the topic can be seen here: https://www.growingwiththeweb.com/2016/07/enabling-pull-requests-on-github-wikis.html

fixed in
4580fda and
0db30baae4c5cf1ad6834ec601a0c3c721d76b43