Friday, December 30, 2016

Digest for comp.lang.c++@googlegroups.com - 20 updates in 6 topics

woodbrian77@gmail.com: Dec 29 09:59PM -0800

On Thursday, December 29, 2016 at 4:25:45 PM UTC-6, Ian Collins wrote:
> > but against the baseless hatred in some "leaders"
 
> So how much do you know about the people and leaders of New Zealand?
> Enough to insult us?
 
G-d loves people from New Zealand, including the leaders. G-d
loved King Herod even though Herod murdered Yohanan the Immerser
(aka John the Baptist). But G-d sent Yohanan and Yeshua (aka
Jesus), in part, to stand up to Herod. Herod didn't respond
well to their rebuke. I'm afraid there's no shortage of corrupt
people like Herod in power today.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Dec 30 09:27PM +1300


>> So how much do you know about the people and leaders of New Zealand?
>> Enough to insult us?
 
> G-d loves people from New Zealand, including the leaders.
 
 
In other words, no. An apology would be appropriate.
 
--
Ian
David Brown <david.brown@hesbynett.no>: Dec 30 10:07AM +0100

> as a "radical individualist". I'm for people,
> but against the baseless hatred in some "leaders"
> -- Putin, Obama ...
 
So you claim to be /for/ the people (of USA, NZ, UK, Russia, etc.), and
against their leaders? Fair enough - there is nothing wrong with having
a political opinion (though it is always much better if it is /informed/
opinion, rather than just knee-jerk reaction).
 
So why do you then insult the /people/ (of USA, etc.) rather than their
leaders?
 
And why do you accuse them of "anti-semitism" - prejudice against Jews
either as a people or as members of a religion? Both the leaders and
the majority of the populace of these countries disapproves of Israel's
/leaders/ and political policies - they have nothing against either the
people of Israel, the Jewish religion, or anything else that could be
construed as anti-semitism. They just don't think that one country
should invade its neighbours and turn that country into a giant prison
camp while stealing their land and resources. The leaders and populace
of USA, etc., don't care if the tyrants behind this plan are Jewish,
Christian, Muslim, Martians, or whatever.
 
The hypocrisy behind your "thinking" is just astounding. It does not
matter how often you quote your old book, or complain about swearing -
you can't claim to be Christian if you don't understand basic humanity
and if you don't follow Jesus' most important rule - love thy neighbour.
 
 
> these "leaders" will have the trap they intended for
> Israel recoil on themselves. I'll be buying products
> from Taiwan and South Korea, rather than China or Japan.
 
Whoa, these countries are in for a shock! When they find out that Brian
is no longer buying products from China and Japan, their economies will
be collapsing in no time. Watch out for that "recoil"!
asetofsymbols@gmail.com: Dec 30 02:49AM -0800

The leaders are choosed many time from peoples but only
in a rose, or in a little set choosed
from elite...
So where is the choose people has?
asetofsymbols@gmail.com: Dec 30 03:17AM -0800

For me it is better leader is the
parliaments so many peoples
not just one...
More people there are in parlaments
better it is
woodbrian77@gmail.com: Dec 30 09:51AM -0800

On Friday, December 30, 2016 at 2:27:59 AM UTC-6, Ian Collins wrote:
 
> > G-d loves people from New Zealand, including the leaders.
 
> In other words, no. An apology would be appropriate.
 
If I were planning a trip to your part of the world, I'd
go to Australia.
 
"Australian Foreign Minister claims that if it had had a say,
Australia would not have voted for the recent "one-sided" UN resolution."
 
http://www.israelnationalnews.com/News/News.aspx/222531
 
I've never been to Australia or New Zealand, but
Austrailia is looking like they still have a heart.
 
 
Brian
Ebenezer Enterprises - Enjoy programming again.
http://webEbenezer.net
interval1066@gmail.com: Dec 30 10:43AM -0800

On Monday, December 26, 2016 at 1:51:38 PM UTC-8, Jeff-Relf.Me wrote:
> Macros are _good_, you should use them.
 
Sure. Microsoft created a whole language out of them. Its called MFC.
Wouter van Ooijen <wouter@voti.nl>: Dec 30 07:46PM +0100

> go to Australia.
 
> "Australian Foreign Minister claims that if it had had a say,
> Australia would not have voted for the recent "one-sided" UN resolution."
 
one-sided?
 
ROFL!
 
Wouter "Objects? No Thanks!" van Ooijen
Jeff-Relf.Me <@.>: Dec 30 02:17PM -0800

interval1066@gmail.com: Dec 30 11:10AM -0800

On Tuesday, December 27, 2016 at 3:16:37 AM UTC-8, Rick C. Hodgin wrote:
> one. You'll find every one holds up to the most intense scrutiny, and
> every aspect of observable science because it is the truth.
 
> Truth has a name, Ian: Jesus.
 
too busy to jump all over this guy flibble, or taking it easy for the holidays?
Mr Flibble <flibble@i42.co.uk>: Dec 29 11:26PM

On 29/12/2016 21:56, Tim Rentsch wrote:
> the order, so I guess there is no need to explain further.
 
> The problem of finding the middle element of a list while
> traversing the list once does make an amusing little exercise.
 
Yes I have thought about that problem and I am guessing it involves
powers of 2 if you know what I mean. :)
 
/Flibble
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:25PM -0800

>> traversing the list once does make an amusing little exercise.
 
> Yes I have thought about that problem and I am guessing it involves
> powers of 2 if you know what I mean. :)
 
I don't know about other folks but my solution involves
exactly two powers of 2 -- 2**0 and 2**1.
David Brown <david.brown@hesbynett.no>: Dec 30 09:48AM +0100

On 29/12/16 18:43, Gareth Owen wrote:
>> set), while the set
 
> That's not what we were taught re bounded and unbounded. The definition
> I was taught was to do with there being a metric, and that there was a
 
(You need an order, not a metric - though a metric can give you an order.)
 
 
> ∃r ∈ ℝ such that ||x|| < r ∀x ∈ S
 
The set {x ∈ ℝ : x > 0 and x < 1} is bounded within ℝ, but not as a
stand-alone set by itself, as the limits are not inside the set. That's
why we have to be careful about the details here.
 
So the set of non-negative integers is normally called "unbounded"
because it has no limit within the set. But viewed as ordinals, they
/have/ a limit - ω₀, so within the set of countable ordinals, the finite
ordinals are infinite but bounded.
 
 
It is a /long/ time since I was at university, so I can't be entirely
sure that my terminology is correct here. But I think you can
understand what I mean.
 
 
Gareth Owen <gwowen@gmail.com>: Dec 30 11:37AM


> The set {x ∈ ℝ : x > 0 and x < 1} is bounded within ℝ, but not as a
> stand-alone set by itself, as the limits are not inside the set. That's
> why we have to be careful about the details here.
 
Again, "contains all its limit points" is one of the usual equivalent
definitions of closed set. For that you don't need an order, but you do
need a topology.
 
> because it has no limit within the set. But viewed as ordinals, they
> /have/ a limit - ω₀, so within the set of countable ordinals, the finite
> ordinals are infinite but bounded.
 
Then we were taught different nomenclature.
 
> It is a /long/ time since I was at university, so I can't be entirely
> sure that my terminology is correct here. But I think you can
> understand what I mean.
 
Oh, I understand completely, you're just using different terms than I'm
used to. As you gave your definitions, it was totally comprehensible.
David Brown <david.brown@hesbynett.no>: Dec 30 01:23PM +0100

On 30/12/16 12:37, Gareth Owen wrote:
 
> Again, "contains all its limit points" is one of the usual equivalent
> definitions of closed set. For that you don't need an order, but you do
> need a topology.
 
It sounds like I am mixing up my definitions here, and I'm grateful to
you for stirring up my old memories and bringing them to the surface again.
 
When I had been talking about "bounded", I really meant /closed and
bounded/ - i.e., the bounds are within the set. But you are correct -
to be bounded, a set needs to have limits but the limits do not have to
be in the set.
 
>> /have/ a limit - ω₀, so within the set of countable ordinals, the finite
>> ordinals are infinite but bounded.
 
> Then we were taught different nomenclature.
 
No, you just remember it better :-)
 
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 30 07:41AM +0100

Part 3. This tutorial, if it works (it's an experiment), is intended to
work this way:
 
* I post some working code.
* Learner(s) study it and ask about things.
* Others answer questions and post critique or get bogged down in long
sub-threads about sausages and swearing.
 
Part 2 added logic to maintain a height difference value in each node.
Namely, height of right subtree minus height of left subtree. One nice
thing about a difference, as opposed to just storing the heights
directly, is that when balancing is introduced the diff can be encoded
in just 2 bits, e.g., for joy-joy hacking delight, in the least
significant bits of the pointers – but I'm not going to do that. :)
 
Tim Rentsch suggested an alternative way to do the updating, using O(1)
memory instead of O(log n) memory as in the code I posted. That's one
reason for this posting. Another reason is that I'd like comments on my
thoughts about balancing, outlined at the end here, before I code it up.
 
----------------------------------------------------------------------
 
The part 2 updating code, using O(log n) memory, looked like this:
 
// Called after a new node, the `p_new_child`, has been inserted:
void update_height_differences(
Node* const p_new_child,
stack<Node*> parent_nodes
)
{
Node* p_child = p_new_child;
while( not parent_nodes.empty() )
{
Node* const p_parent = popped_top_of(
parent_nodes );
int& height_diff = p_parent->height_diff;
int const old_height_diff = height_diff;
 
height_diff += (p_parent->right == p_child? +1 : -1);
 
bool const this_height_increased =
(abs( height_diff ) > abs( old_height_diff ));
if( not this_height_increased )
{
break;
}
p_child = p_parent;
}
}
 
void add( Value const& value )
{
stack<Node*> parent_nodes;
Node** p_ptr = &root_;
while( *p_ptr != nullptr )
{
Node*& ref_ptr = *p_ptr;
parent_nodes.push( ref_ptr );
p_ptr = &(value < ref_ptr->value? ref_ptr->left :
ref_ptr->right);
}
*p_ptr = new Node{ nullptr, nullptr, value, 0 };
update_height_differences( *p_ptr, move( parent_nodes ) );
}
 
An implementation of Tim's suggested O(1) memory updating, which as I
understand it is a common implementation:
 
// Called after a new node with value `new_value` has been inserted:
static void update_height_differences_down_from(
Node* const highest_node_with_change,
Value const& new_value
)
{
Node* node = highest_node_with_change;
while( node )
{
bool const go_left = (new_value < node->value);
bool const is_leaf_node = not(node->left or node->right);
if( not is_leaf_node )
{
node->height_diff += (go_left? -1 : +1);
}
node = (go_left? node->left : node->right);
}
}
 
void add( Value const& value )
{
Node** p_ptr = &root_;
Node* lowest_newheight_absorber = nullptr;
while( *p_ptr != nullptr )
{
Node*& ref_ptr = *p_ptr;
bool const go_left = (value < ref_ptr->value);
bool const go_right = not go_left;
bool const right_is_higher = (ref_ptr->height_diff > 0);
bool const left_is_higher = (ref_ptr->height_diff < 0);
 
if( go_left and right_is_higher or go_right and
left_is_higher )
{
lowest_newheight_absorber = ref_ptr;
}
 
p_ptr = &(go_left? ref_ptr->left : ref_ptr->right);
}
 
*p_ptr = new Node{ nullptr, nullptr, value, 0 };
update_height_differences_down_from(
lowest_newheight_absorber? lowest_newheight_absorber : root_,
value
);
}
 
I haven't measured these but the O(1) memory scheme avoids any dynamic
allocation even for the most naïve direct implementation, so for the
case of non-optimized code it should be faster.
 
It brings more complexity to the `add` member function, and simplifies
the `update_height_differences`... function.
 
----------------------------------------------------------------------
 
My thinking about balancing.
 
I've yet to read up on this in Wikipedia. Hopefully that won't be
necessary! :) I think the last I read about it was in Wirth's Algorithms
+ Data Structures = Programs, around 1984.
 
Basic idea for the situation at the left below, put current root at
maximum right of its left of subtree (its value is guaranteed greater):
 
|
40
/ |
30 → 30
/ / \
20 20 40
/ / \
10 10 30
 
How a naïve implementation can then produce an equally bad tree:
 
|
40
/ \ |
30 45 → 30
/ \ / \
20 35 20 35
/ / \
10 10 40
\
45
 
One fix is to make current root R = 40 the right subtree of its left
node N = 30, put current right subtree of N as left subtree of R:
 
|
40
/ \ |
30 45 → 30
/ \ / \
20 35 20 40
/ / / \
10 10 35 45
 
But is this all, modulo symmetry for the opposite imbalance?
 
 
Cheers!, & Happy New Year soon!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 30 01:57AM +0100

On 29.12.2016 23:31, Tim Rentsch wrote:
> }
 
> So, for what it's worth, that is now the best suggestion I have
> to offer.
 
Oh, thanks! I need to really fasten that with duct tape back of my
skull, because it's not the first time! Some years ago I was enquiring
here about another difficult-for-me thing, a scheme for generating
extensions of options classes in a class derivation hierarchy
(essentially to do the same thing as passing named option values in e.g.
Python, especially for GUI stuff), and James Kanze suggested, hey, why
don't you just preprocess using a script?
 
Somehow the thought didn't enter my mind.
 
I ended up doing a different all C++ complicated template thing, which I
subsequently wrote a DDJ article about, but I think that was mostly
because I had such a momentum in that direction, not really a free
choice. The preprocessing is the rational thing to do. Thanks!
 
 
Cheers!,
 
- Alf
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:31PM -0800

> (essentially to do the same thing as passing named option values in
> e.g. Python, especially for GUI stuff), and James Kanze suggested,
> hey, why don't you just preprocess using a script?
 
You are most welcome sir. It's always nice to hear that a
suggestion is found to be both helpful and appreciated. :)
Ben Bacarisse <ben.usenet@bsb.me.uk>: Dec 30 02:23AM

Tim Rentsch <txr@alumni.caltech.edu> writes:
<snip>
> or 40 years ago. A good starting point is the paper by
> James Morris, "Types are not Sets":
 
> http://dl.acm.org/citation.cfm?id=582168
 
That seems to be the wrong link. I find it at:
 
http://dl.acm.org/citation.cfm?doid=512927.512938
 
--
Ben.
Tim Rentsch <txr@alumni.caltech.edu>: Dec 29 08:27PM -0800


>> http://dl.acm.org/citation.cfm?id=582168
 
> That seems to be the wrong link. I find it at:
 
> http://dl.acm.org/citation.cfm?doid=512927.512938
 
Yes, thank you, that's the link I meant. Somehow I mistakenly
copied the wrong link from my clipboard.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: