This file contains 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
# 追加したメソッドをパイプラインで使いたいが... | |
$foo = "abc" | Add-Member ScriptMethod Repeat{ | |
param( | |
[Parameter(ValueFromPipeline=$True)]$n | |
) | |
$this * $n | |
} -PassThru | |
$foo.Repeat(5) #=> abcabcabcabcabc |
This file contains 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
# 追加したメソッドをパイプラインで使いたい | |
$foo = "abc" | Add-Member ScriptMethod Repeat{ | |
param($n) | |
$this * $n | |
} -PassThru | |
#Helper で対応 | |
filter Invoke-Method($method){ | |
$method.Invoke($_) |
This file contains 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
;;-*- coding: utf-8 -*- | |
(ns tenki.core | |
(:require [clojure.xml :as xml] | |
[clojure.zip :as zip] | |
[clojure.data.zip.xml :refer :all] | |
[clojure.core.cache :as cache])) | |
(defn city-url | |
[city-id] | |
(->> city-id (format "http://tenki.jp/component/static_api/rss/forecast/city_%d.xml"))) |
This file contains 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
/* | |
* C++11 (VisualStudio 2013 Express Edition) | |
* boost 1.55.0 | |
*/ | |
#include <iostream> | |
#include <boost/coroutine/all.hpp> | |
#include <boost/range/irange.hpp> | |
#include <boost/multiprecision/cpp_int.hpp> |
This file contains 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
/* | |
* C++11 (VisualStudio 2013 Express Edition) | |
* boost 1.55.0 | |
*/ | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <boost/coroutine/all.hpp> |
This file contains 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
# | |
# 既知の素数リストを保存しているファイルを読み込み | |
# 続きから素数を列挙する | |
# | |
# 素数リストファイルは | |
# primes000.txt, primes001.txt, primes002.txt ... | |
# と複数ファイルに分割されていても良い。 | |
# ファイル番号の順に内容を連結した時、素数が昇順に並んでいること。 | |
# 新たな素数は、ファイル番号最大+1のファイル名で保存します。 | |
# |
This file contains 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
(defn k | |
([x] (format "%sかわいいよ%" x)) | |
([] (k "λ"))) |
This file contains 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
#lang racket | |
;; | |
;; queue%クラスのメソッド enqueue, dequeue を producer%, consumer%だけに公開している。 | |
;; let の外部からはこの2メソッドは見えない。 | |
;; | |
(define-values (queue% producer% consumer%) | |
(let () | |
(define-member-name enqueue (generate-member-key)) |
This file contains 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
#lang racket | |
(require racket/gui) | |
(define font (make-font #:size 40 | |
#:size-in-pixels? #t | |
#:face "HGGyoshotai")) | |
(define font-size (send font get-point-size)) | |
(define font-size-half (/ font-size 2)) | |
(define rotate-text-hash '#hash(("ー" . #t))) |
This file contains 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
(ns program | |
(:import System.IO.EndOfStreamException) | |
(:import clojure.lang.Compiler+CompilerException) | |
(:gen-class)) | |
(defn try-eval [line v] | |
(let [v (conj v (str "\n" line))] | |
(try | |
[true (-> (apply str v) read-string eval) []] | |
(catch EndOfStreamException e [false nil v]) |
OlderNewer