link ximage
procedure main()
local s :=set([1,2,3]), x
local t :=list(s), i :=0
repeat { # every x := !s do
x := t[i+:=1]
if *s> 10 then {
stop("finished")
}
write("x: ", x)
write("s before insert: ", ximage(s))
insert(s, x + 10) & put(t, x + 10)
write("s after insert: ", ximage(s))
}
end
,Sergey,I've seen a couple of approaches to this (both ugly). The second less so.1. Keep a second structure for inserts, take a second pass and move them when they are listed. Repeat until empty.2. Keep marker structure and mark processed objects, take a second pass. Repeat until no new items are unmarked (*markers = *structures).David
From: "Jeffery, Clint (jeffe...@uidaho.edu)" <jeffe...@uidaho.edu>
To: Unicon group <unicon-group@lists.sourceforge.net>
Sent: Monday, January 18, 2016 3:26 AM
Subject: Re: [Unicon-group] Question relating to the semantics of !x
Sets and tables are implemented in the Icon/Unicon VM using open hash tables. You effectively have an array of linked lists, and ! just walks down each linked list, starting with bucket 0. The reason order is undefined is that hashing generally is supposed to toss them into buckets fairly randomly. The reason ! does not guarantee to generate newly inserted elements if it is in the middle of generating all of them is that newly inserted elements are as likely to be placed in an earlier bucket as they are in a bucket that is not yet visited.Bruce, you will indeed need to devise something more than just !, such as a scheme that marks elements that have been generated, and is smart enough to restart the generation of elements if the size is changed, skipping elements that have already been generated. That's not too bad, but sorry that ! is not magically smart enough to do it all for you.Cheers,ClintI need also to mention about ! operator following. The Unicon Programming Language book describes that "Set and table elements are generated in an undefined order." So, the order of results for "every !set" is undefined. It should be taken into account.Sergey18.01.2016, 08:49, "Bruce & Breeanna Rennie" <bren...@dcsi.net.au>:Thank you, you have answered my question. The fact that ! is undefined
if the structure is modified during generation explains why there is a
difference between the two versions.
I have a small program that I am writing in which I wanted to add
elements to a set during the loop and have them appear in the generation
of the elements via !. However, I will now look at an alternative process.
regards
Bruce Rennie
On 18/01/16 14:13, Jeffery, Clint (jeffe...@uidaho.edu) wrote:Hi Bruce,
Behavior of ! is undefined if the structure is modified during
generation. Given that, what questions would you want to pose?
Cheers, Clint
-------- Original message --------
From: Bruce & Breeanna Rennie <bren...@dcsi.net.au>
Date: 01/17/2016 5:13 PM (GMT-08:00)
To: Unicon group <unicon-group@lists.sourceforge.net>
Subject: [Unicon-group] Question relating to the semantics of every
... do
Good afternoon all,
I have a question relating to the semantics of every do
what would be the expected sequence of results for x in the following
program in terms of what
procedure main()
local s := set([1, 2, 3]), x
every x := !s do {
write("x: ", x)
write("s before insert: ", ximage(s))
insert(s, x < 30 & x + 2)
write("s after insert: ", ximage(s))
}
end
link ximage
is the value of s in !s evaluated only once at the start of the loop
even though a value is inserted into s during the loop? I am getting
somewhat inconsistent results as the following version gives a different
number of times around loop.
procedure main()
local s := set([1, 2, 3]), x
every x := !s do {
if *s > 10 then {
stop("finished")
}
write("x: ", x)
write("s before insert: ", ximage(s))
insert(s, x + 10)
write("s after insert: ", ximage(s))
}
end
link ximage
regards
Bruce Rennie
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group------------------------------------------------------------------------------
,
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
Unicon-group mailing list
Unicon-group@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/unicon-group
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________ Unicon-group mailing list Unicon-group@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/unicon-group