Click here to Skip to main content
15,896,557 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: HOTD Pin
Mark_Wallace10-Apr-15 10:56
Mark_Wallace10-Apr-15 10:56 
GeneralRe: HOTD Pin
Sander Rossel10-Apr-15 8:56
professionalSander Rossel10-Apr-15 8:56 
GeneralRe: HOTD Pin
dandy7210-Apr-15 9:01
dandy7210-Apr-15 9:01 
GeneralRe: HOTD Pin
Mark_Wallace10-Apr-15 10:04
Mark_Wallace10-Apr-15 10:04 
GeneralRe: HOTD Pin
OriginalGriff10-Apr-15 10:34
mveOriginalGriff10-Apr-15 10:34 
GeneralRe: HOTD Pin
Slacker00710-Apr-15 9:14
professionalSlacker00710-Apr-15 9:14 
GeneralRe: HOTD Pin
JimmyRopes10-Apr-15 19:26
professionalJimmyRopes10-Apr-15 19:26 
GeneralThought of the day PinPopular
OriginalGriff10-Apr-15 5:18
mveOriginalGriff10-Apr-15 5:18 
C#
using System;
using System.Linq.Expressions;

namespace Shakespeare
    {
    static class Hamlet
        {
        static T TheQuestion<T>(T b)
            {
            return Or<T>.Do(Add<T>.Do(b, b), Not<T>.Do(Add<T>.Do(b, b)));
            }
        }
    public static class Add<T>
        {
        public static readonly Func<T, T, T> Do;

        static Add()
            {
            var par1 = Expression.Parameter(typeof(T));
            var par2 = Expression.Parameter(typeof(T));
            var add = Expression.Add(par1, par2);

            Do = Expression.Lambda<Func<T, T, T>>(add, par1, par2).Compile();
            }
        }
    public static class Or<T>
        {
        public static readonly Func<T, T, T> Do;

        static Or()
            {
            var par1 = Expression.Parameter(typeof(T));
            var par2 = Expression.Parameter(typeof(T));
            var or = Expression.Or(par1, par2);

            Do = Expression.Lambda<Func<T, T, T>>(or, par1, par2).Compile();
            }
        }
    public static class Not<T>
        {
        public static readonly Func<T, T> Do;

        static Not()
            {
            var par = Expression.Parameter(typeof(T));
            var not = Expression.Not(par);
            Do = Expression.Lambda<Func<T, T>>(not, par).Compile();
            }
        }
    }


Hah! Generic Shakespeare clone!

With thanks to xanatos[^] - and if I use code like that for real, shoot me...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: Thought of the day PinPopular
Bergholt Stuttley Johnson10-Apr-15 5:26
professionalBergholt Stuttley Johnson10-Apr-15 5:26 
GeneralRe: Thought of the day Pin
Bassam Abdul-Baki10-Apr-15 6:25
professionalBassam Abdul-Baki10-Apr-15 6:25 
GeneralRe: Thought of the day Pin
Sascha Lefèvre10-Apr-15 5:42
professionalSascha Lefèvre10-Apr-15 5:42 
GeneralRe: Thought of the day Pin
OriginalGriff10-Apr-15 6:07
mveOriginalGriff10-Apr-15 6:07 
GeneralRe: Thought of the day Pin
Mark_Wallace10-Apr-15 6:05
Mark_Wallace10-Apr-15 6:05 
GeneralRe: Thought of the day Pin
OriginalGriff10-Apr-15 6:17
mveOriginalGriff10-Apr-15 6:17 
GeneralRe: Thought of the day Pin
Mark_Wallace10-Apr-15 6:38
Mark_Wallace10-Apr-15 6:38 
GeneralRe: Thought of the day Pin
Corporal Agarn10-Apr-15 6:38
professionalCorporal Agarn10-Apr-15 6:38 
GeneralRe: Thought of the day Pin
Mladen Janković10-Apr-15 15:52
Mladen Janković10-Apr-15 15:52 
GeneralRe: Thought of the day Pin
OriginalGriff10-Apr-15 22:28
mveOriginalGriff10-Apr-15 22:28 
GeneralNo, Microsoft, I'm not in the habit of stealing your OS... Pin
OriginalGriff10-Apr-15 4:26
mveOriginalGriff10-Apr-15 4:26 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Eddy Vluggen10-Apr-15 4:41
professionalEddy Vluggen10-Apr-15 4:41 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Bergholt Stuttley Johnson10-Apr-15 4:57
professionalBergholt Stuttley Johnson10-Apr-15 4:57 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Eddy Vluggen10-Apr-15 5:16
professionalEddy Vluggen10-Apr-15 5:16 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Bergholt Stuttley Johnson10-Apr-15 5:24
professionalBergholt Stuttley Johnson10-Apr-15 5:24 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Eddy Vluggen10-Apr-15 5:47
professionalEddy Vluggen10-Apr-15 5:47 
GeneralRe: No, Microsoft, I'm not in the habit of stealing your OS... Pin
Mark_Wallace10-Apr-15 6:12
Mark_Wallace10-Apr-15 6:12 

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.