On Tuesday, February 25, 2025 at 7:57:50 AM UTC Nuno Cruces wrote:

I'm… sorry. I don't understand the purpose of this code listing.

In my original post I gave a solution to my own problem implemented in two 
ways: with goroutines and channels, and with newcoro and coroswitch. If 
you're trying to show me that I don't need either of those, that iter.Seq 
is enough, I would kindly ask that you reconsider, and try to implement my 
interface that way. I don't think it's possible, but I'll be really happy 
if you can prove me wrong.


Hi Nuno,

It feels like the problem you specified is not the actual problem you have 
in mind.
An X/Y issue, as you suggest.

It would help us to help you, if that is your wish, if you were to define 
the 
problem with more rigor--not in code--just in words. Stay high level for a 
moment,
and try to clearly specify the actual problem you are thinking of. I tried
to read your code but could not discern your intent from it.  It can also
help to start from an example problem (not code) or two, and then to
generalize those to a clear, precise, problem statement; this provides 
motivation and intent,
which can also be helpful.

The problem specification you originally gave was this:

> "to implement... a "processor" function that accepts an iter.Seq and 
returns a result:
>    func processor(seq iter.Seq[value]) result { ... }"

This is exactly the consumeAndSum() function example that I provided;
consumeAndSum() is a "processor" by your definition. It accepts an
iter.Seq and returns a result (the sum).

Moreover, you originally said,
"I've been cracking my head, and I'm convinced I can't with just 
iter.Seq/iter.Pull"

Which says, in contradiction to your later comment/claim, that you did not 
have a solution
when you asked for one.

The code I provided demonstrates that a solution to the stated problem is 
indeed possible
with iter.Seq.

Best wishes,
Jason


 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/766882e2-7df4-472a-9ecc-a2ebe31e53cen%40googlegroups.com.

Reply via email to