June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

36
Task/Amb/C-sharp/amb-4.cs Normal file
View file

@ -0,0 +1,36 @@
using System.Linq;
using static System.Console;
namespace Amb
{
class Program
{
static void Main(string[] args)
{
var amb = new Amb();
var set1 = amb.Choose("the", "that", "a");
var set2 = amb.Choose("frog", "elephant", "thing");
amb.Require(() => set1.Value.Last() == set2.Value[0]);
var set3 = amb.Choose("walked", "treaded", "grows");
amb.Require(() => set2.Value.Last() == set3.Value[0]);
var set4 = amb.Choose("slowly", "quickly");
amb.RequireFinal(() => set3.Value.Last() == set4.Value[0]);
WriteLine($"{set1} {set2} {set3} {set4}");
Read();
// problem from http://www.randomhacks.net/articles/2005/10/11/amb-operator
amb = new Amb();
var x = amb.Choose(1, 2, 3);
var y = amb.Choose(4, 5, 6);
amb.RequireFinal(() => x.Value* y.Value == 8);
WriteLine($"{x} * {y} = 8");
Read();
Read();
}
}
}