ListValues provides the constants that make up the list via callback.
(cbCons func(Constant) error, cbNil func() error)
| 493 | |
| 494 | // ListValues provides the constants that make up the list via callback. |
| 495 | func (c Constant) ListValues(cbCons func(Constant) error, cbNil func() error) (error, error) { |
| 496 | if c.Type != ListShape { |
| 497 | return fmt.Errorf("not a list constant %v", c), nil |
| 498 | } |
| 499 | for ; !c.IsListNil(); c = *c.snd { |
| 500 | if err := cbCons(*c.fst); err != nil { |
| 501 | return nil, err |
| 502 | } |
| 503 | } |
| 504 | return nil, cbNil() |
| 505 | } |
| 506 | |
| 507 | // ListSeq returns an iterator over the list elements. |
| 508 | func (c Constant) ListSeq() (iter.Seq[Constant], error) { |