Kim,
Thanks for the report. I believe delete() didn't support lists
initially, but it did late in the game. There is no reason for it to not
have the same semantics as other language features when it comes to
indices. I've just committed a change to address this.
Below is a sample program/run,
Cheers,
Jafar
procedure main()
H := []
every put(H, 1 to 10)
every writes(!H, " ")| write ("")
delete(H, 0)
every writes(!H, " ")| write ("")
delete(H, -1)
every writes(!H, " ")| write ("")
delete(H, -2, -1)
every writes(!H, " ")| write ("")
delete(H, -1, -2)
every writes(!H, " ")| write ("")
end
OUTPUT:
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7
1 2 3 4 6
On Sat, Mar 22, 2014 at 6:18 AM, Kim <[email protected]> wrote:
> Unicon extends delete(x1, x2, ...) to allow deletion of items from lists.
> According to the Unicon book, p. 312, 'If x1 is a list... elements xi are
> integer indices of the element to be deleted.'
>
> Negative indices into lists are allowed in other contexts, e.g. if L is a
> list, L[-1] returns the same element as L[*L]. But negative indices do not
> work with delete(). The following code produces the output listed below:
>
> procedure main()
>
> write(&version)
> write()
>
> H := []
> every put(H, 1 to 10)
> write("Size of H is ", *H)
>
> delete(H, -1)
> write("delete(H, -1)")
> write("Size of H is ", *H)
>
> delete(H, *H)
> write("delete(H, *H)")
> write("Size of H is ", *H)
>
> end
>
> Unicon Version 12.1. April 13, 2013
>
> Size of H is 10
> delete(H, -1)
> Size of H is 10
> delete(H, *H)
> Size of H is 9
>
> I would expect the statement
> delete(H, -1)
> to delete the last element of H. But it does nothing at all.
>
>
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Unicon-group mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/unicon-group
>
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group