type LogicGate =
| ON
| OFF
| NAND of LogicGate * LogicGate
| NOT of LogicGate
| AND of LogicGate * LogicGate
| OR of LogicGate * LogicGate
| NOR of LogicGate * LogicGate
| XOR of LogicGate * LogicGate
| XNOR of LogicGate * LogicGate
let rec evaluate input =
match input with
| ON -> true
| OFF -> false
| NAND(a, b) -> not ((evaluate a) && (evaluate b))
| NOT(a) -> (evaluate (NAND(a, a)))
| AND(a, b) -> (evaluate (NOT(NAND(a, b))))
| OR(a, b) -> (evaluate (NAND(NOT(a), NOT(b))))
| NOR(a, b) -> (evaluate (NOT(OR(a, b))))
| XOR(a, b) -> (evaluate (AND(NAND(a, b), OR(a, b))))
| XNOR(a, b) -> (evaluate (NOT(XOR(a, b))))
[
NAND(OFF, OFF);
NAND(OFF, ON);
NAND(ON, OFF);
NAND(ON, ON)
] |> List.map (fun x -> printfn (evaluate x)) open System
open System.Collections.Generic
open System.Reflection
type Config = string
type ISuperPlugin =
abstract member Name : string
abstract member Initialize : Config -> unit
let loadedPlugins = Dictionary<string,ISuperPlugin>()
let isPlugin (tp: Type) =
tp.GetInterfaces()
|> Seq.exists (fun t -> t.GetType() = typeof<ISuperPlugin>)
let isPluginLoaded plugin =
match loadedPlugins.TryGetValue(plugin) with
| true, v -> true
| _ -> false
let loadPlugin typ = () // implement this
let LoadPluginsFromAssembly path =
let asm = Assembly.LoadFrom path
asm.GetTypes()
|> Seq.filter isPlugin
|> Seq.filter (fun t -> not (isPluginLoaded t.Name))
|> Seq.map loadPlugin
|> ignore
let loadAllPlugins plugins =
plugins
|> Seq.map (fun p -> async { LoadPluginsFromAssembly p })
|> Async.Parallel
|> ignore
Loads a bunch of plugins from assemblies in parallel. Haven't tested it but it should work with minor modifications to make it thread-safe. public abstract class LogicGate
{
public abstract bool Evaluate();
}
public abstract class BinaryLogic : LogicGate
{
protected LogicGate a, b;
public BinaryLogic(LogicGate a, LogicGate b)
{
this.a = a;
this.b = b;
}
}
public class ON : LogicGate
{
public override bool Evaluate() { return true; }
}
public class OFF : LogicGate
{
public override bool Evaluate() { return false; }
}
public class NAND : BinaryLogic
{
public NAND(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate()
{
return !(a.Evaluate() && b.Evaluate());
}
}
public class NOT : LogicGate
{
LogicGate a;
public NOT(LogicGate a)
{
this.a = a;
}
public override bool Evaluate()
{
return new NAND(a, a).Evaluate();
}
}
public class AND : BinaryLogic
{
public AND(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate()
{
return new NOT(new NAND(a, b)).Evaluate();
}
}
public class OR : BinaryLogic
{
public OR(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate()
{
return new NAND(new NOT(a), new NOT(b)).Evaluate();
}
}
public class NOR : BinaryLogic
{
public NOR(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate()
{
return new NOT(new OR(a, b)).Evaluate();
}
}
public class XOR : BinaryLogic
{
public XOR(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate()
{
return new AND(new NAND(a, b), new OR(a, b)).Evaluate();
}
}
public class XNOR : BinaryLogic
{
public XNOR(LogicGate a, LogicGate b) : base(a, b) { }
public override bool Evaluate() { return new NOT(new XOR(a, b)).Evaluate(); }
}
class Program
{
public static void Main(string[] args)
{
var on = new ON();
var off = new OFF();
var result = new List<LogicGate>()
{
new NAND(on, off),
new NAND(off, on),
new NAND(on, off),
new NAND(on, on)
}
.Select(x => x.Evaluate());
Console.WriteLine(result);
}
} type 't heap = Empty | Heap of 't * 't heap list
let findmin (Heap(x,_)) = x
let merge h1 h2 =
match (h1,h2) with
| Empty,h | h,Empty -> h
| Heap(x,h1s),Heap(y,h2s) -> if x < y then Heap(x,h2::h1s) else Heap(y,h1::h2s)
let deletemin (Heap(_,hs)) = List.fold merge Empty hs
let insert h x = merge h (Heap(x,[]))type LogicGate = | ON | OFF | NOR of LogicGate * LogicGate | NOT of LogicGate | AND of LogicGate * LogicGate | OR of LogicGate * LogicGate | NAND of LogicGate * LogicGate | XOR of LogicGate * LogicGate | XNOR of LogicGate * LogicGate
let rec evaluate input =
match input with
| ON -> true
| OFF -> false
| NOR(a, b) -> not ((evaluate a) || (evaluate b))
| NOT(a) -> (evaluate (NOR(a, a)))
| OR(a, b) -> (evaluate (NOT(NOR(a, b))))
| AND(a, b) -> (evaluate (NOR(NOT(a), NOT(b))))
| NAND(a, b) -> (evaluate (NOT(AND(a, b))))
| XNOR(a, b) -> (evaluate (OR(AND(a, b), NOR(a, b))))
| XOR(a, b) -> (evaluate (NOT(XNOR(a, b))))
[
NOR(OFF, OFF);
NOR(OFF, ON);
NOR(ON, OFF);
NOR(ON, ON)
] |> List.map (fun x -> printfn (evaluate x))The confidence of the SuperCollider programming language has been set to 80%. The reason for this is quite funny. In order to prove that the TIOBE index can be manipulated easily, Adam Kennedy created an empty Perl library called Acme-SuperCollider-Programming. This was to boost the unknown programming language SuperCollider by adding it to Perl's popular library archive CPAN. Now 20% of all +"SuperCollider programming" come from this artificial library.
Yes, quite funny indeed, but not for the reasons they think. Just to show that Tiobe methodology is a joke. I don't understand how people take this seriously.
Having working with the raw data, it was pretty fantastic. Segemented by industry/business size, handled issues with multiple programming languages or companies where one section used one language and another used other ones, etc. We even knew which tools and add-ons were used for which languages and which compiler on each platform (i.e. how many commercial shops using C++ targeting linux are using gcc vs. icc?).
But that data was also stunningly expensive. My marketing friends tell me that accurate market data always is.
1) I use more metrics and
2) I don't go around making statements about how, from one month to the next, someone displaced someone else, or climbed into a certain ranking, or things like that.
3) I let people reweight the chart based on the metrics they like.
I think the numbers LangPop comes up with are pretty good, but by their very nature are a bit fuzzy.
I couldn't put it in the submission because of HN's dupe detection.