Deutsch   English   Français   Italiano  
<6710a0eb$0$706$14726298@news.sunsite.dk>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!fu-berlin.de!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: "digi_cs" <cosmogen@gmail.com>
Subject: HID: LIST arrays
Newsgroups: comp.lang.awk
Date: Thu, 17 Oct 2024 08:26:35 +0300
Lines: 63
Message-ID: <6710a0eb$0$706$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: 8661efd3.news.sunsite.dk
X-Trace: 1729143020 news.sunsite.dk 706 cosmogen@gmail.com/85.253.129.232:56289
X-Complaints-To: staff@sunsite.dk
Bytes: 2181

Hello!

FYI

      @include “github.com/digics/UID10/uid.lib”      

      LIST = hid::get( “LIST” )


An array (A) in AWK can represent a list of unique items with an undefined order.
To introduce the concept of an array with a defined sequence of its indexes (items),
we need to specify this sequence in a subarray A[LIST] as a simple list:

The element A[ LIST ][ "" ] stores the index of the first item in the list:
      
      # items of A: first, next and last:

      A[ LIST ][ “” ] = “first”
               [ “first” ] = “next”
               [ “next” ] = “last”
               [ “last” [ = “”

       [ “first” ]...
       [ “next” ]...
       [ “last” ]...

Thus, instead of a for-in loop for array A, we use: 

      i = “”

      while ( “” != i = A[ LIST][ i ] )

            # process A[ i ]

or

      for ( i = “”; “” != i = A[ LIST ][ i ]; ) 

            # process A[ i ]

At the same time, we can still work with the main array in a for-in loop — with one caveat: 

      for ( i in A )
      
            if ( i in HID )

                  continue          # this is hid (LIST)

            else

                  # process A[ i ]

In case a bidirectional list is needed, another subarray A[LIST][LIST] is created
within the subarray A[LIST], where the items are listed in reverse order,
 and the element A[LIST][LIST][""] stores the index of the last item in the list. 

best regards)


--------------=  Posted using GrabIt  =----------------
------=  Binary Usenet downloading made easy =---------
-=  Get GrabIt for free from https://www.shemes.com/  =-