Just like Haskell, operators can be used as a function.
var d = 40
d + 1 // 41
(+)(d, 2) // 42
#ifdef __cplusplus | |
extern "C" { | |
#endif /* __cplusplus */ | |
#include <stdio.h> | |
#include <ctype.h> | |
int isNaN(double d) { | |
char buf[32]; | |
sprintf(buf, "+%f", d); |
// | |
// cf. http://nomothetis.svbtle.com/smashing-swift | |
// | |
extension Dictionary { | |
func map<R>(transform:(ValueType)->R)->Dictionary<KeyType, R> { | |
var result:Dictionary<KeyType, R> = [:] | |
for (k, v) in self { | |
result[k] = transform(v) | |
} | |
return result |
// | |
// main.swift | |
// church | |
// | |
// Created by Dan Kogai on 6/15/14. | |
// Copyright (c) 2014 Dan Kogai. All rights reserved. | |
// | |
/* Operators */ |
import Foundation | |
if C_ARGC < 2 { | |
println("\(C_ARGV[0]) url") | |
exit(-1) | |
} | |
let url = NSURL.URLWithString(String.fromCString(C_ARGV[1])) | |
var enc:NSStringEncoding = NSUTF8StringEncoding | |
var err:NSError? | |
let content = | |
NSString.stringWithContentsOfURL(url, usedEncoding:&enc, error:&err) |
import Foundation | |
if C_ARGC < 2 { | |
println("\(C_ARGV[0]) url") | |
exit(-1) | |
} | |
let url = NSURL.URLWithString(String.fromCString(C_ARGV[1])) | |
var enc:NSStringEncoding = NSUTF8StringEncoding | |
var err:NSError? | |
let content = | |
NSString.stringWithContentsOfURL(url, usedEncoding:&enc, error:&err) |
% cat /usr/ports/shells/bash/pkg-message | |
====================================================================== | |
bash requires fdescfs(5) mounted on /dev/fd and procfs(5) mounted on | |
/proc. | |
If you have not done it yet, please do the following: | |
mount -t fdescfs fdesc /dev/fd | |
mount -t procfs proc /proc |
--- bsfilter.1.0.18rc5 Sun Mar 10 03:03:03 2013 | |
+++ bsfilter Mon Jul 1 02:52:54 2013 | |
@@ -933,24 +933,27 @@ | |
if (str.force_encoding('ASCII-8BIT') =~ reg_gb18030_possible) | |
gb18030_possible = true | |
end | |
- | |
- if (str.encode('UTF-8', 'UTF-8') =~ reg_utf8) | |
- @options["message-fh"].printf("lang ja utf8\n") if (@options["debug"]) | |
- return ["ja", "utf8"] |
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Spec; | |
our $VERSION = sprintf "%d.%02d", q$Revision: 0.1 $ =~ /(\d+)/g; | |
sub usage { exec 'pod2usage', $0 or die "pod2usage: $!" } | |
my $cmd = '/usr/bin/osascript'; | |
die "$0 : $cmd nonexistent" unless -x $cmd; | |
my @paths = grep { -e $_ } map { File::Spec->rel2abs($_) } @ARGV; |
% perl -E 'system qw[perl -E], q[say %{{"a".."z"}}] for 1..100' |