Part of const array with same value

TQ <[email protected]> Fri, 6 Dec 2019 19:33:25 -0800
Newsgroups gmane.comp.security.detection.bro
Message-ID <CAM2MKSpuMp=9mhs15ZDYB8xVb_XC061r_XndF1jNrsgUkjeeAw@mail.gmail.com>
--===============1129720768==
Content-Type: multipart/alternative; boundary="0000000000004e6bbd059914d57e"

--0000000000004e6bbd059914d57e
Content-Type: text/plain; charset="UTF-8"

Hello Zeekers,

What is the best way to represent indices of an array with the same value?
Let's say I declare a constant string array used for enumeration called
'test'.  Values 0 and 1 has some unique value, but anything from 2 and 7
has a constant value of 'test2'.  Is there a quicker way of representing
this or would I need to manually set it?

const test = {
    [0] = "test0",
    [1] = "test1",
    [2] = "test2",
    [3] = "test2",
    [4] = "test2",
    [5] = "test2",
    [6] = "test2",
    [7] = "test2",
    [8] = "test3",
    } &default=function(i: count):string { return fmt("test(%x)", i); }
&redef;

Thanks,

--0000000000004e6bbd059914d57e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello Zeekers,<br><div><br></div><div>What is the best way=
 to represent indices of an array with the same value?=C2=A0 Let&#39;s say =
I declare a constant string array used for enumeration called &#39;test&#39=
;.=C2=A0 Values 0 and 1 has some unique value, but anything from 2 and 7 ha=
s a constant value of &#39;test2&#39;.=C2=A0 Is there a quicker way of repr=
esenting this or would I need to manually set it?</div><div><br></div><div>=
const test =3D {<br>=C2=A0 =C2=A0 [0] =3D &quot;test0&quot;,<br>=C2=A0 =C2=
=A0 [1] =3D &quot;test1&quot;,</div><div><div>=C2=A0 =C2=A0 [2] =3D &quot;t=
est2&quot;,<br>=C2=A0 =C2=A0 [3] =3D &quot;test2&quot;,</div><div><div>=C2=
=A0 =C2=A0 [4] =3D &quot;test2&quot;,<br>=C2=A0 =C2=A0 [5] =3D &quot;test2&=
quot;,</div><div></div></div><div></div><div><div>=C2=A0 =C2=A0 [6] =3D &qu=
ot;test2&quot;,<br>=C2=A0 =C2=A0 [7] =3D &quot;test2&quot;,</div><div>

=C2=A0 =C2=A0 [8] =3D &quot;test3&quot;,

<br></div><div></div></div>=C2=A0 =C2=A0 } &amp;default=3Dfunction(i: count=
):string { return fmt(&quot;test(%x)&quot;, i); } &amp;redef;<br></div><div=
><br></div><div>Thanks,</div></div>

--0000000000004e6bbd059914d57e--

--===============1129720768==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Zeek mailing list
[email protected]
http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/zeek
--===============1129720768==--