Click here to Skip to main content
15,897,518 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 10:52
professionalSander Rossel16-Aug-19 10:52 
GeneralRe: when algorithms attack Pin
Jon McKee17-Aug-19 10:19
professionalJon McKee17-Aug-19 10:19 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 10:34
professionalSander Rossel17-Aug-19 10:34 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 10:30
mvahoney the codewitch16-Aug-19 10:30 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 10:59
professionalSander Rossel16-Aug-19 10:59 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:02
mvahoney the codewitch16-Aug-19 11:02 
GeneralRe: when algorithms attack Pin
Sander Rossel16-Aug-19 11:09
professionalSander Rossel16-Aug-19 11:09 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 11:16
mvahoney the codewitch16-Aug-19 11:16 
Here's a private method that computes the LR Item sets (one of the first steps at the link). In C#

it may as well be in C++. All LRItem is is basically a "tuple" (string Left, IList<string> Right, int RightIndex) except it implements value semantics (they can be compared)

C#
static void _FillLRClosureInPlace(CfgDocument cfg,IProgress<CfgLalr1Progress> progress, ICollection<LRItem> result)
{
	var done = false;
	while (!done)
	{
		done = true;
		var l = result.ToArray();
		for (var i = 0; i < l.Length; ++i)
		{
			if(null!=progress)
				progress.Report(new CfgLalr1Progress(CfgLalr1Status.ComputingClosure, i));
			var item = l[i];
			var next = item.RightIndex < item.Rule.Right.Count ? item.Rule.Right[item.RightIndex] : null;
			if (item.RightIndex < item.Rule.Right.Count)
			{
				if (cfg.IsNonTerminal(next))
				{
					for (int jc = cfg.Rules.Count, j = 0; j < jc; ++j)
					{
						var r = cfg.Rules[j];
						if (r.Left == next)
						{
							var lri = new LRItem(r, 0);
							if (!result.Contains(lri))
							{
								done = false;
								result.Add(lri);
							}
						}
					}
				}
			}
		}
	}
}

When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.


modified 16-Aug-19 17:24pm.

GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 1:35
professionalSander Rossel17-Aug-19 1:35 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 3:16
mvahoney the codewitch17-Aug-19 3:16 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:08
professionalSander Rossel17-Aug-19 4:08 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:14
mvahoney the codewitch17-Aug-19 4:14 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:27
professionalSander Rossel17-Aug-19 4:27 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:30
mvahoney the codewitch17-Aug-19 4:30 
GeneralRe: when algorithms attack Pin
Sander Rossel17-Aug-19 4:32
professionalSander Rossel17-Aug-19 4:32 
GeneralRe: when algorithms attack Pin
honey the codewitch17-Aug-19 4:41
mvahoney the codewitch17-Aug-19 4:41 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:06
dandy7216-Aug-19 5:06 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:08
mvahoney the codewitch16-Aug-19 5:08 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:11
dandy7216-Aug-19 5:11 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:12
mvahoney the codewitch16-Aug-19 5:12 
GeneralRe: when algorithms attack Pin
dandy7216-Aug-19 5:16
dandy7216-Aug-19 5:16 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 5:20
mvahoney the codewitch16-Aug-19 5:20 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 9:31
professionalJon McKee16-Aug-19 9:31 
GeneralRe: when algorithms attack Pin
honey the codewitch16-Aug-19 9:35
mvahoney the codewitch16-Aug-19 9:35 
GeneralRe: when algorithms attack Pin
Jon McKee16-Aug-19 10:33
professionalJon McKee16-Aug-19 10:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   150 votes