Re: [go-nuts] Imitating tuple in golang

2024-08-08 Thread Gergely Brautigam
My apologies the link is incorrect. It should be https://github.com/Skarlso/tuple Hopefully it’s somewhat of a help in pursuing this topic. On Friday 9 August 2024 at 07:57:33 UTC+2 Gergely Brautigam wrote: > Hello. > > I actually implemented a Tupke logic here https://github.con/Skarlso/tuple

Re: [go-nuts] Imitating tuple in golang

2024-08-08 Thread Gergely Brautigam
My apologies for the link. Google groups on mobile isn’t really working. https://girhub.com/Skarlso/tuple On Friday 9 August 2024 at 07:57:33 UTC+2 Gergely Brautigam wrote: > Hello. > > I actually implemented a Tupke logic here https://github.con/Skarlso/tuple > . > > I find this a much better

Re: [go-nuts] Imitating tuple in golang

2024-08-08 Thread Gergely Brautigam
Hello. I actually implemented a Tupke logic here https://github.con/Skarlso/tuple. I find this a much better way to deal with tuples instead of the indexing logic. And it’s using generics as well. Feel free to borrow stuff. 😊 On Friday 9 August 2024 at 02:19:22 UTC+2 Jolyon Direnko-Smith wrote

Re: [go-nuts] Imitating tuple in golang

2024-08-08 Thread Jolyon Direnko-Smith
My $0.02 on this First, to address the use cases in your question, Golang does not have custom operators so the value of tuples in assisting with their implementation is moot. (and, IMHO, should resist incorporating them; someone should not have to consult the source for a type to understand w

Re: [go-nuts] Imitating tuple in golang

2024-08-08 Thread Jan Mercl
On Thu, Aug 8, 2024 at 9:35 PM 'lijh8' via golang-nuts wrote: > I try to use slice of any to imitate the tuple type, > and use this function to compare two slices: a, b. > > How can I improve it? Take a look at https://pkg.go.dev/slices#Compare if it can fit your use case. -- You received this

[go-nuts] Imitating tuple in golang

2024-08-08 Thread 'lijh8' via golang-nuts
Hi community, I try to use slice of any to imitate the tuple type, and use this function to compare two slices: a, b. How can I improve it? Thanks ``` package tuple2 func Cmp(a, b []any) (int, bool) { for i := 0; i != min(len(a), len(b)); i++ { if a[i] == nil && b[i]