Skip to content

Instantly share code, notes, and snippets.

function CalculateRelative($path,$pathRelative)
{
$parts1 = ($path.ToString()).Split("\")
$parts2 = ($pathRelative.ToString()).Split("\")
$prefixEqual = 0
$min = [Math]::Min($parts1.Length, $parts2.Length)
$continue = $true
while($prefixEqual -lt $min)
{
if ($parts1[$prefixEqual] -ne $parts2[$prefixEqual])
@ldfallas
ldfallas / ScParser.hs
Created February 10, 2012 10:47
A small parser for Scheme-like expressions
module SCParser where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
module SCPPrint where
import SCParser
import Text.PrettyPrint.HughesPJ
--toStringP :: Expr -> String
toStringP (ScSymbol name) = text name
toStringP (ScNumber num) = text $ show num
toStringP (ScDouble num) = text $ show num
data Expr = ScSymbol String
| ScString String
| ScNumber Integer
| ScDouble Double
| ScCons Expr Expr
| ScNil
| ScBool Bool
| ScQuote Expr
deriving Show
@ldfallas
ldfallas / ScParser.hs
Created January 18, 2012 12:36
Another experiment of a toy-Scheme parser
module SCParser where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
@ldfallas
ldfallas / SCParser.hs
Created January 17, 2012 12:13
Small experiment of Scheme-like parser
module SCParser where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
module Experiment where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
module Experiment where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
@ldfallas
ldfallas / gist:1570370
Created January 6, 2012 12:26
Little Parsec experiment
module Experiment where
import Text.Parsec
import Text.Parsec.Token
import Text.Parsec.Language
data Expr = ScSymbol String
| ScString String
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:utils="clr-namespace:Langexplr;assembly=utils"
Title="Little query" Width="300" Height="300">
<Window.Resources>
<utils:TreeViewSelectedHelper x:Key="selHelper" />
</Window.Resources>
<StackPanel>
<TextBlock Text="??"/>