Robert,
You are asking a classic Icon question, one so classic that any number of
experts on the list might weigh in on the best solution. You are correct
that l[2:0] creates a copy of (most of) l -- not a good thing if l is
large. Instead of generating elements from a slice via
!l[2:0]
one can certainly generate the elements with
l[2 to *l]
Can anyone else suggest a shorter/cleaner formulation of Robert's
writeany() procedure? Is there an IPL procedure that already does this?
Cheers,
Clint
On Sat, Mar 8, 2014 at 10:24 AM, Robert Heckendorn <captainmeer...@gmail.com
> wrote:
> The following can write out a list. I don't like doing the slice of the
> list because I am worried it builds a copy of the list. Any comments?
>
> procedure writeany(l)
> every writes("[" |
> l[1] |
> ", " || !l[2:0] |
> "]")
> write()
> end
>
> procedure main()
> l := ["a", "b", "c"]
> writeany(l)
> pop(l)
>
> writeany(l)
> pop(l)
>
> writeany(l)
> pop(l)
>
> writeany(l)
>
> writeany("dogs")
>
> end
>
> --
>
> ------------------------------------------------------------------------------
> |
> | "People would rather believe than know." -- E. O. Wilson
> |
> | Dr. Robert Heckendorn
> | captainmeer...@gmail.com
> | http://marvin.cs.uidaho.edu/~heckendo
> | Computer Science Dept, Univ. of Idaho, Moscow, Idaho, USA 83844-1010
>
>
------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works.
Faster operations. Version large binaries. Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group