This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Codec.Text.IConv as IConv | |
import Codec.Binary.UTF8.String as UTF8 | |
import Data.ByteString as B | |
import Data.ByteString.Lazy as BL | |
import System.IO as IO | |
convertDetect :: [ IConv.EncodingName ] -> IConv.EncodingName -> BL.ByteString -> | |
Either BL.ByteString (IConv.EncodingName, BL.ByteString) | |
convertDetect [] _ src = Left src | |
convertDetect (srcEnc:srcEncs) dstEnc src = case IConv.convertStrictly srcEnc dstEnc src of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | Polymorphic version of @Codec.Archive.LibZip@. | |
Codec.Archive.Libzip is with useful and simple API, and a high-leveled library to deal with zip archives. | |
...Although, in the library, specification way of the path to a file inside a zip archive is `String`. | |
This limitation is inconvenient especially when dealing with zip archived file | |
of which path contains foreign system's multi-byte characters. | |
This module provides APIs of polymorphic version, | |
which can specify and receive archived file's path as String or Data.ByteString (as you like). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import sys | |
def zigzag(sig, steps): | |
while True: | |
yield (sig, steps) | |
sig *= -1 | |
steps += 1 | |
def locus(x, motion): | |
i = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-42) | |
(define (dfs E0 E R vs) | |
(match vs | |
[ () 0] | |
[ (v . vs) | |
(max-ec (:range e 0 (+ E 1)) | |
(+ (* v e) | |
(dfs E0 | |
(min E0 (+ E R (- e))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/mzscheme/src/bool.c Sat Jun 01 00:04:45 2013 +0900 | |
+++ b/src/mzscheme/src/bool.c Sat Jun 01 00:12:44 2013 +0900 | |
@@ -124,6 +124,9 @@ | |
return SAME_OBJ(obj1, obj2); | |
} | |
+#ifdef MZ_XFORM | |
+START_XFORM_SKIP; | |
+#endif | |
XFORM_NONGCING static MZ_INLINE int double_eqv(double a, double b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gosh -V | |
Gauche scheme shell, version 0.9.3 [utf-8,pthreads], x86_64-unknown-linux-gnu | |
% gosh precomp -e -P -o even--odd even-odd.scm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FizzBuzz = Either Int String | |
hit :: String -> FizzBuzz -> FizzBuzz | |
hit s (Left _) = Right s | |
hit s (Right s') = Right $ s ++ s' | |
fizz :: [ FizzBuzz -> FizzBuzz ] | |
fizz = cycle [ id, id, hit "fizz" ] | |
buzz :: [ FizzBuzz -> FizzBuzz ] | |
buzz = cycle [ id, id, id, id, hit "buzz" ] | |
fizzbuzz :: [ FizzBuzz -> FizzBuzz ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env gosh | |
(for-each (.$ display ucs->char length) | |
'#0=(#1=(#0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0# . | |
#2=(#0##0##0##0##0##0##0##0##0##0##0# . | |
#3=(#0# . #4=(#0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0# . #0#)))) | |
#5=(#0# . #6=(#0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0##0# . #1#)) | |
#7=(#0##0##0##0##0##0##0# . #5#) | |
#7##8=(#0##0##0# . #7#) | |
#2##4##9=(#0##0##0##0##0# . #10=(#0##0##0# . #8#)) #8##10##7##6##3#)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
use strict; | |
use IO::File; | |
use IPC::Open2; | |
my $ofh = IO::File->new_tmpfile; | |
for (my $i = 1; $i < 20; ++$i) { | |
print $ofh ('x' x $i), "\n"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
use strict; | |
use IO::File; | |
use IPC::Open2; | |
my $ifh0 = IO::Handle->new; | |
my $ifh1 = IO::File->new_tmpfile; | |
my $ofh0 = IO::Handle->new; | |
my $pid0 = open2($ifh0, $ofh0, qw(cat -n)); |