glycerine / zygomys

Zygo is a Lisp interpreter written in 100% Go. Central use case: dynamically compose Go struct trees in a zygo script, then invoke compiled Go functions on those trees. Makes Go reflection easy.
https://github.com/glycerine/zygomys/wiki
BSD 2-Clause "Simplified" License
1.71k stars 81 forks source link

Wiki: Generic Container needing some fix #38

Closed jkleiser closed 5 years ago

jkleiser commented 5 years ago

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.

glycerine commented 5 years ago

A PR would be welcome.

jkleiser commented 5 years ago

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

glycerine commented 5 years ago

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.

glycerine commented 5 years ago

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

jkleiser commented 5 years ago

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?

glycerine commented 5 years ago

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.

jkleiser commented 5 years ago

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

glycerine commented 5 years ago

ok

glycerine commented 5 years ago

fixed in 4580fdae07f1e804c83922c9754ba2399ce36572 and 0db30baae4c5cf1ad6834ec601a0c3c721d76b43