Hi Andy --

On Thu, Mar 28, 2024 at 01:06:10PM +0000, Andy Bunce scripsit:
> hof:until is not gone, it is just hiding  [1]
> - In 10.7 it is there but undocumented in Wiki

Which is useful to know -- thank you! -- but makes me think a bunch of
my production code is going to break hard when 11 is released. I would
really like to avoid that. (In particular, the conversation with
management about how much refactoring work will be required.)

> - In BaseX 11 you need to use XQuery 4  fn:while-do⁺, fn:do-until⁺ [2]

It is very probably my brain, but I'm having trouble transposing
hof:until to those functions. I can an implement what I want to do with
hof:until like so:

declare function xc:dropTableLinesFancy($in as node()*) as node()* { 
  let $result as map(*) := 
    hof:until(
      (: are we done? (= we've run off the end of our list of nodes ) :)
      function($m) { 
         empty($m?oldNodes)
    },
      (: create new list of line elements :)
      function($m) {
          map {
            'oldNodes': tail($m?oldNodes),
            'newNodes': ($m?newNodes,
              switch (true())
                case starts-with(head($m?oldNodes),':stab') return <line/>
                case starts-with(head($m?oldNodes),':rtab') return <line/>
                case $m?toggle return <line/>
                default return head($m?oldNodes)
              ),
            'toggle': (
              switch (true())
                case starts-with(head($m?oldNodes),':stab') return true()
                case starts-with(head($m?oldNodes),':rtab') return false()
                default return $m?toggle
              ) 
          }
      },
      (: initial input = we start with no new nodes :)
      map { 'oldNodes': $in, 'newNodes': (), 'toggle': false() }
    )
  return $result?newNodes
};

Anyone willing to provide an example of what that would look like in 
fn:while-do or fn:do-until? 

Thanks!
Graydon


-- 
Graydon Saunders  | graydon...@fastmail.com
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")

Reply via email to