Merge branch 'master' into 985

Conflicts:
	lib/linguist/languages.yml
This commit is contained in:
Arfon Smith
2014-05-04 09:04:28 -05:00
14 changed files with 1468 additions and 82 deletions

View File

@@ -2,11 +2,8 @@ before_install:
- sudo apt-get install libicu-dev -y
- gem update --system 2.1.11
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.1
- ree
notifications:
disabled: true

View File

@@ -1,7 +1,2 @@
source 'https://rubygems.org'
gemspec
if RUBY_VERSION < "1.9.3"
# escape_utils 1.0.0 requires 1.9.3 and above
gem "escape_utils", "0.3.2"
end

View File

@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.executables << 'linguist'
s.add_dependency 'charlock_holmes', '~> 0.6.6'
s.add_dependency 'escape_utils', '>= 0.3.1'
s.add_dependency 'escape_utils', '~> 1.0.1'
s.add_dependency 'mime-types', '~> 1.19'
s.add_dependency 'pygments.rb', '~> 0.5.4'

View File

@@ -9,7 +9,7 @@
# includes name.downcase)
# ace_mode - A String name of Ace Mode (if available)
# wrap - Boolean wrap to enable line wrapping (default: false)
# extension - An Array of associated extensions (the first one is
# extensions - An Array of associated extensions (the first one is
# considered the primary extension)
# interpreters - An Array of associated interpreters
# searchable - Boolean flag to enable searching (defaults to true)
@@ -91,7 +91,8 @@ Alloy:
type: programming # 'modeling' would be more appropiate
lexer: Text only
color: "#cc5c24"
primary_extension: .als
extensions:
- .als
ApacheConf:
type: markup
@@ -144,7 +145,8 @@ AspectJ:
type: programming
lexer: AspectJ
color: "#1957b0"
primary_extension: .aj
extensions:
- .aj
Assembly:
type: programming
@@ -167,7 +169,7 @@ AutoHotkey:
color: "#6594b9"
aliases:
- ahk
extension:
extensions:
- .ahk
AutoIt:
@@ -490,13 +492,13 @@ DM:
type: programming
color: "#075ff1"
lexer: C++
extension:
extensions:
- .dm
aliases:
- byond
DOT:
type: programming
type: data
lexer: Text only
extensions:
- .dot
@@ -533,7 +535,8 @@ Dogescript:
type: programming
lexer: Text only
color: "#cca760"
primary_extension: .djs
extensions:
- .djs
Dylan:
type: programming
@@ -547,7 +550,8 @@ E:
type: programming
color: "#ccce35"
lexer: Text only
primary_extension: .E
extensions:
- .E
Ecere Projects:
type: data
@@ -568,8 +572,8 @@ Eagle:
type: markup
color: "#3994bc"
lexer: XML
primary_extension: .sch
extensions:
- .sch
- .brd
Eiffel:
@@ -690,17 +694,19 @@ Frege:
type: programming
color: "#00cafe"
lexer: Haskell
primary_extension: .fr
extensions:
- .fr
Game Maker Language:
type: programming
color: "#8ad353"
lexer: JavaScript
primary_extension: .gml
extensions:
- .gml
GAP:
type: programming
lexer: Text only
primary_extension: .g
extensions:
- .g
- .gap
@@ -765,8 +771,8 @@ Gnuplot:
type: programming
color: "#f0a9f0"
lexer: Gnuplot
primary_extension: .gp
extensions:
- .gp
- .gnu
- .gnuplot
- .plot
@@ -790,7 +796,8 @@ Grammatical Framework:
aliases:
- gf
wrap: false
primary_extension: .gf
extensions:
- .gf
searchable: true
color: "#ff0000"
@@ -927,7 +934,8 @@ INI:
- .properties
Inno Setup:
primary_extension: .iss
extensions:
- .iss
lexer: Text only
Idris:
@@ -941,8 +949,8 @@ Inform 7:
type: programming
lexer: Text only
wrap: true
primary_extension: .ni
extensions:
- .ni
- .i7x
Inno Setup:
@@ -1013,7 +1021,8 @@ JSONiq:
type: programming
ace_mode: jsoniq
lexer: XQuery
primary_extension: .jq
extensions:
- .jq
Jade:
group: HTML
@@ -1080,7 +1089,8 @@ Kit:
type: markup
lexer: HTML
ace_mode: html
primary_extension: .kit
extensions:
- .kit
Kotlin:
type: programming
@@ -1113,7 +1123,8 @@ Latte:
color: "#A8FF97"
group: HTML
lexer: Smarty
primary_extension: .latte
extensions:
- .latte
Less:
type: markup
@@ -1131,7 +1142,8 @@ LilyPond:
Liquid:
type: markup
lexer: Text only
primary_extension: .liquid
extensions:
- .liquid
Literate Agda:
type: programming
@@ -1207,7 +1219,8 @@ MTML:
type: markup
lexer: HTML
color: "#0095d9"
primary_extension: .mtml
extensions:
- .mtml
Makefile:
aliases:
@@ -1249,7 +1262,8 @@ Mask:
Mathematica:
type: programming
primary_extension: .mathematica
extensions:
- .mathematica
lexer: Text only
Matlab:
@@ -1283,11 +1297,7 @@ MediaWiki:
Mercury:
type: programming
# This is the background colour on the web page.
color: "#abcdef"
# The primary extension is .m, but lingist won't accept duplicates
primary_extension: .mercury
# Mercury's syntax is not prolog syntax, but they do share the lexer
lexer: Prolog
ace_mode: prolog
extensions:
@@ -1477,7 +1487,7 @@ PAWN:
PHP:
type: programming
ace_mode: php
color: "#6e03c1"
color: "#4F5D95"
extensions:
- .php
- .aw
@@ -1633,7 +1643,8 @@ PureScript:
type: programming
color: "#bcdc53"
lexer: Haskell
primary_extension: .purs
extensions:
- .purs
Python:
type: programming
@@ -1674,6 +1685,7 @@ R:
lexer: S
aliases:
- R
- Rscript
extensions:
- .r
- .R
@@ -1751,6 +1763,14 @@ Rebol:
- .r3
- .rebol
Red:
type: programming
lexer: Text only
color: "#ee0000"
extensions:
- .red
- .reds
Redcode:
extensions:
- .cw
@@ -1907,7 +1927,8 @@ Shell:
ShellSession:
type: programming
lexer: Bash Session
primary_extension: .sh-session
extensions:
- .sh-session
Shen:
type: programming
@@ -1937,7 +1958,8 @@ SourcePawn:
color: "#f69e1d"
aliases:
- sourcemod
primary_extension: .sp
extensions:
- .sp
Squirrel:
type: programming
@@ -1958,14 +1980,13 @@ Stata:
type: programming
lexer: Text only
extensions:
- .ado
- .do
- .ado
- .doh
- .ihlp
- .mata
- .matah
- .sthlp
primary_extension: .do
Stylus:
type: markup
@@ -1985,8 +2006,8 @@ SystemVerilog:
type: programming
color: "#343761"
lexer: systemverilog
primary_extension: .sv
extensions:
- .sv
- .svh
- .vh
@@ -2266,7 +2287,8 @@ Zephir:
type: programming
lexer: PHP
color: "#118f9e"
primary_extension: .zep
extensions:
- .zep
eC:
type: programming

View File

@@ -195,6 +195,9 @@
".handlebars",
".hbs"
],
"Haskell": [
".hs"
],
"HTML": [
".html",
".st"
@@ -458,6 +461,10 @@
".reb",
".rebol"
],
"Red": [
".red",
".reds"
],
"RMarkdown": [
".rmd"
],
@@ -642,6 +649,9 @@
"Perl": [
"ack"
],
"R": [
"expr-dist"
],
"Ruby": [
"Appraisals",
"Capfile",
@@ -681,8 +691,8 @@
".gemrc"
]
},
"tokens_total": 589756,
"languages_total": 713,
"tokens_total": 592149,
"languages_total": 720,
"tokens": {
"ABAP": {
"*/**": 1,
@@ -24917,6 +24927,85 @@
"</h2>": 1,
"/each": 1
},
"Haskell": {
"import": 6,
"Data.Char": 1,
"main": 4,
"IO": 2,
"(": 8,
")": 8,
"do": 3,
"let": 2,
"hello": 2,
"putStrLn": 3,
"map": 13,
"toUpper": 1,
"module": 2,
"Main": 1,
"where": 4,
"Sudoku": 9,
"Data.Maybe": 2,
"sudoku": 36,
"[": 4,
"]": 3,
"pPrint": 5,
"+": 2,
"fromMaybe": 1,
"solve": 5,
"isSolved": 4,
"Data.List": 1,
"Data.List.Split": 1,
"type": 1,
"Int": 1,
"-": 3,
"Maybe": 1,
"|": 8,
"Just": 1,
"otherwise": 2,
"index": 27,
"<": 1,
"elemIndex": 1,
"sudokus": 2,
"nextTest": 5,
"i": 7,
"<->": 1,
"1": 2,
"9": 7,
"checkRow": 2,
"checkColumn": 2,
"checkBox": 2,
"listToMaybe": 1,
"mapMaybe": 1,
"take": 1,
"drop": 1,
"length": 12,
"getRow": 3,
"nub": 6,
"getColumn": 3,
"getBox": 3,
"filter": 3,
"0": 3,
"chunksOf": 10,
"quot": 3,
"transpose": 4,
"mod": 2,
"concat": 2,
"concatMap": 2,
"3": 4,
"27": 1,
"Bool": 1,
"product": 1,
"False": 4,
".": 4,
"sudokuRows": 4,
"/": 3,
"sudokuColumns": 3,
"sudokuBoxes": 3,
"True": 1,
"String": 1,
"intercalate": 2,
"show": 1
},
"HTML": {
"<!DOCTYPE>": 2,
"HTML": 2,
@@ -52212,43 +52301,43 @@
},
"R": {
"df.residual.mira": 1,
"<": 24,
"-": 27,
"function": 7,
"(": 60,
"object": 9,
"<": 46,
"-": 51,
"function": 18,
"(": 219,
"object": 12,
"...": 4,
")": 60,
"{": 7,
")": 220,
"{": 46,
"fit": 2,
"analyses": 1,
"[": 10,
"]": 10,
"return": 7,
"[": 23,
"]": 24,
"return": 8,
"df.residual": 2,
"}": 7,
"}": 46,
"df.residual.lme": 1,
"fixDF": 1,
"df.residual.mer": 1,
"sum": 1,
"object@dims": 1,
"*": 2,
"c": 5,
"+": 3,
"c": 11,
"+": 4,
"df.residual.default": 1,
"q": 2,
"q": 3,
"df": 3,
"if": 3,
"is.null": 1,
"if": 19,
"is.null": 8,
"mk": 2,
"try": 2,
"try": 3,
"coef": 1,
"silent": 2,
"TRUE": 5,
"silent": 3,
"TRUE": 14,
"mn": 2,
"f": 5,
"f": 9,
"fitted": 1,
"inherits": 2,
"inherits": 6,
"|": 3,
"NULL": 2,
"n": 3,
@@ -52256,18 +52345,78 @@
"is.data.frame": 1,
"is.matrix": 1,
"nrow": 1,
"length": 2,
"length": 3,
"k": 3,
"max": 1,
"SHEBANG#!Rscript": 1,
"SHEBANG#!Rscript": 2,
"#": 45,
"MedianNorm": 2,
"data": 11,
"geomeans": 3,
"<->": 1,
"exp": 1,
"rowMeans": 1,
"log": 5,
"apply": 2,
"2": 1,
"cnts": 2,
"median": 1,
"library": 1,
"print_usage": 2,
"file": 4,
"stderr": 1,
"cat": 1,
"spec": 2,
"matrix": 3,
"byrow": 3,
"ncol": 3,
"opt": 23,
"getopt": 1,
"help": 1,
"stdout": 1,
"status": 1,
"height": 7,
"out": 4,
"res": 6,
"width": 7,
"ylim": 7,
"read.table": 1,
"header": 1,
"sep": 4,
"quote": 1,
"nsamp": 8,
"dim": 1,
"outfile": 4,
"sprintf": 2,
"png": 2,
"h": 12,
"hist": 4,
"plot": 7,
"FALSE": 9,
"mids": 4,
"density": 4,
"type": 3,
"col": 4,
"rainbow": 4,
"main": 2,
"xlab": 2,
"ylab": 2,
"for": 3,
"i": 6,
"in": 8,
"lines": 6,
"devnum": 2,
"dev.off": 2,
"size.factors": 2,
"data.matrix": 1,
"data.norm": 3,
"t": 1,
"x": 3,
"/": 1,
"ParseDates": 2,
"lines": 4,
"dates": 3,
"matrix": 2,
"unlist": 2,
"strsplit": 2,
"ncol": 2,
"byrow": 2,
"strsplit": 3,
"days": 2,
"times": 2,
"hours": 2,
@@ -52288,7 +52437,6 @@
"ggplot": 1,
"aes": 2,
"y": 1,
"x": 1,
"geom_point": 1,
"size": 1,
"Freq": 1,
@@ -52296,11 +52444,214 @@
"range": 1,
"ggsave": 1,
"filename": 1,
"plot": 1,
"width": 1,
"height": 1,
"hello": 2,
"print": 1,
"module": 25,
"code": 19,
"available": 1,
"via": 1,
"the": 16,
"environment": 4,
"like": 1,
"it": 3,
"returns.": 1,
"@param": 2,
"an": 1,
"identifier": 1,
"specifying": 1,
"full": 1,
"path": 9,
"search": 5,
"see": 1,
"Details": 1,
"even": 1,
"attach": 11,
"is": 7,
"optionally": 1,
"attached": 2,
"to": 8,
"of": 1,
"current": 2,
"scope": 1,
"defaults": 1,
".": 5,
"However": 1,
"interactive": 2,
"invoked": 1,
"directly": 1,
"from": 3,
"terminal": 1,
"only": 1,
"i.e.": 1,
"not": 4,
"within": 1,
"modules": 4,
"import.attach": 1,
"can": 2,
"be": 7,
"set": 1,
"or": 1,
"depending": 1,
"on": 1,
"user": 1,
"s": 2,
"preference.": 1,
"attach_operators": 3,
"causes": 1,
"emph": 3,
"operators": 3,
"by": 1,
"default": 1,
"path.": 1,
"Not": 1,
"attaching": 1,
"them": 1,
"therefore": 1,
"drastically": 1,
"limits": 1,
"a": 5,
"usefulness.": 1,
"Modules": 1,
"are": 1,
"searched": 1,
"options": 1,
"priority.": 1,
"The": 2,
"directory": 1,
"always": 1,
"considered": 1,
"first.": 1,
"That": 1,
"local": 3,
"./a.r": 1,
"will": 2,
"loaded.": 1,
"Module": 1,
"names": 2,
"fully": 1,
"qualified": 1,
"refer": 1,
"nested": 1,
"paths.": 1,
"See": 1,
"import": 5,
"executed": 1,
"global": 1,
"effect": 1,
"same.": 1,
"When": 1,
"used": 2,
"globally": 1,
"inside": 1,
"newly": 2,
"outside": 1,
"nor": 1,
"other": 2,
"which": 3,
"might": 1,
"loaded": 4,
"@examples": 1,
"@seealso": 3,
"reload": 3,
"@export": 2,
"substitute": 2,
"stopifnot": 3,
"missing": 1,
"&&": 2,
"module_name": 7,
"getOption": 1,
"else": 4,
"class": 4,
"module_path": 15,
"find_module": 1,
"stop": 1,
"attr": 2,
"message": 1,
"containing_modules": 3,
"module_init_files": 1,
"mapply": 1,
"do_import": 4,
"mod_ns": 5,
"as.character": 3,
"module_parent": 8,
"parent.frame": 2,
"mod_env": 7,
"exhibit_namespace": 3,
"identical": 2,
".GlobalEnv": 2,
"name": 9,
"environmentName": 2,
"parent.env": 4,
"export_operators": 2,
"invisible": 1,
"is_module_loaded": 1,
"get_loaded_module": 1,
"namespace": 13,
"structure": 3,
"new.env": 1,
"parent": 9,
".BaseNamespaceEnv": 1,
"paste": 3,
"source": 2,
"chdir": 1,
"envir": 5,
"cache_module": 1,
"exported_functions": 2,
"lsf.str": 2,
"list2env": 2,
"sapply": 2,
"get": 2,
"ops": 2,
"is_predefined": 2,
"%": 2,
"is_op": 2,
"prefix": 3,
"||": 1,
"grepl": 1,
"Filter": 1,
"op_env": 4,
"cache.": 1,
"@note": 1,
"Any": 1,
"references": 1,
"remain": 1,
"unchanged": 1,
"and": 2,
"files": 1,
"would": 1,
"have": 1,
"happened": 1,
"without": 1,
"unload": 2,
"should": 2,
"production": 1,
"code.": 1,
"does": 1,
"currently": 1,
"detach": 1,
"environments.": 1,
"Reload": 1,
"given": 1,
"Remove": 1,
"cache": 1,
"forcing": 1,
"reload.": 1,
"reloaded": 1,
"reference": 1,
"unloaded": 1,
"still": 1,
"work.": 1,
"Reloading": 1,
"primarily": 1,
"useful": 1,
"testing": 1,
"during": 1,
"module_ref": 3,
"rm": 1,
"list": 1,
".loaded_modules": 1,
"whatnot.": 1,
"assign": 1,
"##polyg": 1,
"vector": 2,
"##numpoints": 1,
@@ -52314,8 +52665,7 @@
"pts": 1,
"spsample": 1,
"polyg": 1,
"numpoints": 1,
"type": 1
"numpoints": 1
},
"Racket": {
";": 3,
@@ -52884,6 +53234,249 @@
"print": 4,
"author": 1
},
"Red": {
"Red": 3,
"[": 111,
"Title": 2,
"Author": 1,
"]": 114,
"File": 1,
"%": 2,
"console.red": 1,
"Tabs": 1,
"Rights": 1,
"License": 2,
"{": 11,
"Distributed": 1,
"under": 1,
"the": 3,
"Boost": 1,
"Software": 1,
"Version": 1,
"See": 1,
"https": 1,
"//github.com/dockimbel/Red/blob/master/BSL": 1,
"-": 74,
"License.txt": 1,
"}": 11,
"Purpose": 2,
"Language": 2,
"http": 2,
"//www.red": 2,
"lang.org/": 2,
"#system": 1,
"global": 1,
"#either": 3,
"OS": 3,
"MacOSX": 2,
"History": 1,
"library": 1,
"cdecl": 3,
"add": 2,
"history": 2,
";": 31,
"Add": 1,
"line": 9,
"to": 2,
"history.": 1,
"c": 7,
"string": 10,
"rl": 4,
"insert": 3,
"wrapper": 2,
"func": 1,
"count": 3,
"integer": 16,
"key": 3,
"return": 10,
"Windows": 2,
"system/platform": 1,
"ret": 5,
"AttachConsole": 1,
"if": 2,
"zero": 3,
"print": 5,
"halt": 2,
"SetConsoleTitle": 1,
"as": 4,
"string/rs": 1,
"head": 1,
"str": 4,
"bind": 1,
"tab": 3,
"input": 2,
"routine": 1,
"prompt": 3,
"/local": 1,
"len": 1,
"buffer": 4,
"string/load": 1,
"+": 1,
"length": 1,
"free": 1,
"byte": 3,
"ptr": 14,
"SET_RETURN": 1,
"(": 6,
")": 4,
"delimiters": 1,
"function": 6,
"block": 3,
"list": 1,
"copy": 2,
"none": 1,
"foreach": 1,
"case": 2,
"escaped": 2,
"no": 2,
"in": 2,
"comment": 2,
"switch": 3,
"#": 8,
"mono": 3,
"mode": 3,
"cnt/1": 1,
"red": 1,
"eval": 1,
"code": 3,
"load/all": 1,
"unless": 1,
"tail": 1,
"set/any": 1,
"not": 1,
"script/2": 1,
"do": 2,
"skip": 1,
"script": 1,
"quit": 2,
"init": 1,
"console": 2,
"Console": 1,
"alpha": 1,
"version": 3,
"only": 1,
"ASCII": 1,
"supported": 1,
"Red/System": 1,
"#include": 1,
"../common/FPU": 1,
"configuration.reds": 1,
"C": 1,
"types": 1,
"#define": 2,
"time": 2,
"long": 2,
"clock": 1,
"date": 1,
"alias": 2,
"struct": 5,
"second": 1,
"minute": 1,
"hour": 1,
"day": 1,
"month": 1,
"year": 1,
"Since": 1,
"weekday": 1,
"since": 1,
"Sunday": 1,
"yearday": 1,
"daylight": 1,
"saving": 1,
"Negative": 1,
"unknown": 1,
"#import": 1,
"LIBC": 1,
"file": 1,
"Error": 1,
"handling": 1,
"form": 1,
"error": 5,
"Return": 1,
"description.": 1,
"Print": 1,
"standard": 1,
"output.": 1,
"Memory": 1,
"management": 1,
"make": 1,
"Allocate": 1,
"filled": 1,
"memory.": 1,
"chunks": 1,
"size": 5,
"binary": 4,
"resize": 1,
"Resize": 1,
"memory": 2,
"allocation.": 1,
"JVM": 6,
"reserved0": 1,
"int": 6,
"reserved1": 1,
"reserved2": 1,
"DestroyJavaVM": 1,
"JNICALL": 5,
"vm": 5,
"jint": 5,
"AttachCurrentThread": 1,
"penv": 3,
"p": 3,
"args": 2,
"DetachCurrentThread": 1,
"GetEnv": 1,
"AttachCurrentThreadAsDaemon": 1,
"just": 2,
"some": 2,
"datatypes": 1,
"for": 1,
"testing": 1,
"#some": 1,
"hash": 1,
"FF0000": 3,
"FF000000": 2,
"with": 4,
"instead": 1,
"of": 1,
"space": 2,
"/wAAAA": 1,
"/wAAA": 2,
"A": 2,
"inside": 2,
"char": 1,
"bla": 2,
"ff": 1,
"foo": 3,
"numbers": 1,
"which": 1,
"interpreter": 1,
"path": 1,
"h": 1,
"#if": 1,
"type": 1,
"exe": 1,
"push": 3,
"system/stack/frame": 2,
"save": 1,
"previous": 1,
"frame": 2,
"pointer": 2,
"system/stack/top": 1,
"@@": 1,
"reposition": 1,
"after": 1,
"catch": 1,
"flag": 1,
"CATCH_ALL": 1,
"exceptions": 1,
"root": 1,
"barrier": 1,
"keep": 1,
"stack": 1,
"aligned": 1,
"on": 1,
"bit": 1
},
"RMarkdown": {
"Some": 1,
"text.": 1,
@@ -62441,6 +63034,7 @@
"Groovy Server Pages": 91,
"Haml": 4,
"Handlebars": 69,
"Haskell": 302,
"HTML": 413,
"Hy": 155,
"IDL": 418,
@@ -62514,11 +63108,12 @@
"Protocol Buffer": 63,
"PureScript": 1652,
"Python": 5715,
"R": 392,
"R": 1667,
"Racket": 331,
"Ragel in Ruby Host": 593,
"RDoc": 279,
"Rebol": 533,
"Red": 816,
"RMarkdown": 19,
"RobotFramework": 483,
"Ruby": 3862,
@@ -62619,6 +63214,7 @@
"Groovy Server Pages": 4,
"Haml": 1,
"Handlebars": 2,
"Haskell": 3,
"HTML": 2,
"Hy": 2,
"IDL": 4,
@@ -62692,11 +63288,12 @@
"Protocol Buffer": 1,
"PureScript": 4,
"Python": 7,
"R": 4,
"R": 6,
"Racket": 2,
"Ragel in Ruby Host": 3,
"RDoc": 1,
"Rebol": 6,
"Red": 2,
"RMarkdown": 1,
"RobotFramework": 3,
"Ruby": 17,
@@ -62742,5 +63339,5 @@
"YAML": 2,
"Zephir": 2
},
"md5": "0ab9fe87b3d811ca32ad705d2653b98f"
"md5": "fa38e2b617caaf230146a7adab264419"
}

View File

@@ -98,6 +98,9 @@
# AngularJS
- (^|/)angular([^.]*)(\.min)?\.js$
# D3.js
- (^|\/)d3(\.v\d+)?([^.]*)(\.min)?\.js$
# React
- (^|/)react(-[^.]*)?(\.min)?\.js$

6
samples/Haskell/Hello.hs Normal file
View File

@@ -0,0 +1,6 @@
import Data.Char
main :: IO ()
main = do
let hello = "hello world"
putStrLn $ map toUpper hello

33
samples/Haskell/Main.hs Normal file
View File

@@ -0,0 +1,33 @@
module Main where
import Sudoku
import Data.Maybe
sudoku :: Sudoku
sudoku = [8, 0, 1, 3, 4, 0, 0, 0, 0,
4, 3, 0, 8, 0, 0, 1, 0, 7,
0, 0, 0, 0, 6, 0, 0, 0, 3,
2, 0, 8, 0, 5, 0, 0, 0, 9,
0, 0, 9, 0, 0, 0, 7, 0, 0,
6, 0, 0, 0, 7, 0, 8, 0, 4,
3, 0, 0, 0, 1, 0, 0, 0, 0,
1, 0, 5, 0, 0, 6, 0, 4, 2,
0, 0, 0, 0, 2, 4, 3, 0, 8]
{-
sudoku :: Sudoku
sudoku = [8, 6, 1, 3, 4, 7, 2, 9, 5,
4, 3, 2, 8, 9, 5, 1, 6, 7,
9, 5, 7, 1, 6, 2, 4, 8, 3,
2, 7, 8, 4, 5, 1, 6, 3, 9,
5, 4, 9, 6, 8, 3, 7, 2, 1,
6, 1, 3, 2, 7, 9, 8, 5, 4,
3, 2, 4, 9, 1, 8, 5, 7, 6,
1, 8, 5, 7, 3, 6, 9, 4, 2,
7, 9, 6, 5, 2, 4, 3, 1, 8]
-}
main :: IO ()
main = do
putStrLn $ pPrint sudoku ++ "\n\n"
putStrLn $ pPrint $ fromMaybe [] $ solve sudoku

46
samples/Haskell/Sudoku.hs Normal file
View File

@@ -0,0 +1,46 @@
module Sudoku
(
Sudoku,
solve,
isSolved,
pPrint
) where
import Data.Maybe
import Data.List
import Data.List.Split
type Sudoku = [Int]
solve :: Sudoku -> Maybe Sudoku
solve sudoku
| isSolved sudoku = Just sudoku
| otherwise = do
index <- elemIndex 0 sudoku
let sudokus = [nextTest sudoku index i | i <- [1..9],
checkRow (nextTest sudoku index i) index,
checkColumn (nextTest sudoku index i) index,
checkBox (nextTest sudoku index i) index]
listToMaybe $ mapMaybe solve sudokus
where nextTest sudoku index i = take index sudoku ++ [i] ++ drop (index+1) sudoku
checkRow sudoku index = (length $ getRow sudoku index) == (length $ nub $ getRow sudoku index)
checkColumn sudoku index = (length $ getColumn sudoku index) == (length $ nub $ getColumn sudoku index)
checkBox sudoku index = (length $ getBox sudoku index) == (length $ nub $ getBox sudoku index)
getRow sudoku index = filter (/=0) $ (chunksOf 9 sudoku) !! (quot index 9)
getColumn sudoku index = filter (/=0) $ (transpose $ chunksOf 9 sudoku) !! (mod index 9)
getBox sudoku index = filter (/=0) $ (map concat $ concatMap transpose $ chunksOf 3 $ map (chunksOf 3) $ chunksOf 9 sudoku)
!! (3 * (quot index 27) + (quot (mod index 9) 3))
isSolved :: Sudoku -> Bool
isSolved sudoku
| product sudoku == 0 = False
| map (length . nub) sudokuRows /= map length sudokuRows = False
| map (length . nub) sudokuColumns /= map length sudokuColumns = False
| map (length . nub) sudokuBoxes /= map length sudokuBoxes = False
| otherwise = True
where sudokuRows = chunksOf 9 sudoku
sudokuColumns = transpose sudokuRows
sudokuBoxes = map concat $ concatMap transpose $ chunksOf 3 $ map (chunksOf 3) $ chunksOf 9 sudoku
pPrint :: Sudoku -> String
pPrint sudoku = intercalate "\n" $ map (intercalate " " . map show) $ chunksOf 9 sudoku

101
samples/R/filenames/expr-dist Executable file
View File

@@ -0,0 +1,101 @@
#!/usr/bin/env Rscript
# Copyright (c) 2013 Daniel S. Standage, released under MIT license
#
# expr-dist: plot distributions of expression values before and after
# normalization; visually confirm that normalization worked
# as expected
#
# Program input is a matrix of expression values, each row corresponding to a
# molecule (gene, transcript, etc) and each row corresponding to that molecule's
# expression level or abundance. The program expects the rows and columns to be
# named, and was tested primarily on output produced by the
# 'rsem-generate-data-matrix' script distributed with the RSEM package.
#
# The program plots the distributions of the logged expression values by sample
# as provided, then normalizes the values, and finally plots the distribution of
# the logged normalized expression values by sample. The expectation is that all
# samples' distributions will have a similar shape but different medians prior
# to normalization, and that post normalization they will all have an identical
# median to facilitate cross-sample comparison.
# MedianNorm function borrowed from the EBSeq library version 1.1.6
# See http://www.bioconductor.org/packages/devel/bioc/html/EBSeq.html
MedianNorm <- function(data)
{
geomeans <- exp( rowMeans(log(data)) )
apply(data, 2, function(cnts) median((cnts/geomeans)[geomeans > 0]))
}
library("getopt")
print_usage <- function(file=stderr())
{
cat("
expr-dist: see source code for full description
Usage: expr-dist [options] < expr-matrix.txt
Options:
-h|--help: print this help message and exit
-o|--out: STRING prefix for output files; default is 'expr-dist'
-r|--res: INT resolution (dpi) of generated graphics; default is 150
-t|--height: INT height (pixels) of generated graphics; default is 1200
-w|--width: INT width (pixels) of generated graphics; default is 1200
-y|--ylim: REAL the visible range of the Y axis depends on the first
distribution plotted; if other distributions are getting
cut off, use this setting to override the default\n\n")
}
spec <- matrix( c("help", 'h', 0, "logical",
"out", 'o', 1, "character",
"res", 'r', 1, "integer",
"height", 't', 1, "integer",
"width", 'w', 1, "integer",
"ylim", 'y', 1, "double"),
byrow=TRUE, ncol=4)
opt <- getopt(spec)
if(!is.null(opt$help))
{
print_usage(file=stdout())
q(status=1)
}
if(is.null(opt$height)) { opt$height <- 1200 }
if(is.null(opt$out)) { opt$out <- "expr-dist" }
if(is.null(opt$res)) { opt$res <- 150 }
if(is.null(opt$width)) { opt$width <- 1200 }
if(!is.null(opt$ylim)) { opt$ylim <- c(0, opt$ylim) }
# Load data, determine number of samples
data <- read.table(file("stdin"), header=TRUE, sep="\t", quote="")
nsamp <- dim(data)[2] - 1
data <- data[,1:nsamp+1]
# Plot distribution of expression values before normalization
outfile <- sprintf("%s-median.png", opt$out)
png(outfile, height=opt$height, width=opt$width, res=opt$res)
h <- hist(log(data[,1]), plot=FALSE)
plot(h$mids, h$density, type="l", col=rainbow(nsamp)[1], main="",
xlab="Log expression value", ylab="Proportion of molecules", ylim=opt$ylim)
for(i in 2:nsamp)
{
h <- hist(log(data[,i]), plot=FALSE)
lines(h$mids, h$density, col=rainbow(nsamp)[i])
}
devnum <- dev.off()
# Normalize by median
size.factors <- MedianNorm(data.matrix(data))
data.norm <- t(apply(data, 1, function(x){ x / size.factors }))
# Plot distribution of normalized expression values
outfile <- sprintf("%s-median-norm.png", opt$out)
png(outfile, height=opt$height, width=opt$width, res=opt$res)
h <- hist(log(data.norm[,1]), plot=FALSE)
plot(h$mids, h$density, type="l", col=rainbow(nsamp)[1], main="",
xlab="Log normalized expression value", ylab="Proportion of molecules",
ylim=opt$ylim)
for(i in 2:nsamp)
{
h <- hist(log(data.norm[,i]), plot=FALSE)
lines(h$mids, h$density, col=rainbow(nsamp)[i])
}
devnum <- dev.off()

201
samples/R/import.r Normal file
View File

@@ -0,0 +1,201 @@
#' Import a module into the current scope
#'
#' \code{module = import('module')} imports a specified module and makes its
#' code available via the environment-like object it returns.
#'
#' @param module an identifier specifying the full module path
#' @param attach if \code{TRUE}, attach the newly loaded module to the object
#' search path (see \code{Details})
#' @param attach_operators if \code{TRUE}, attach operators of module to the
#' object search path, even if \code{attach} is \code{FALSE}
#' @return the loaded module environment (invisible)
#'
#' @details Modules are loaded in an isolated environment which is returned, and
#' optionally attached to the object search path of the current scope (if
#' argument \code{attach} is \code{TRUE}).
#' \code{attach} defaults to \code{FALSE}. However, in interactive code it is
#' often helpful to attach packages by default. Therefore, in interactive code
#' invoked directly from the terminal only (i.e. not within modules),
#' \code{attach} defaults to the value of \code{options('import.attach')}, which
#' can be set to \code{TRUE} or \code{FALSE} depending on the users preference.
#'
#' \code{attach_operators} causes \emph{operators} to be attached by default,
#' because operators can only be invoked in R if they re found in the search
#' path. Not attaching them therefore drastically limits a modules usefulness.
#'
#' Modules are searched in the module search path \code{options('import.path')}.
#' This is a vector of paths to consider, from the highest to the lowest
#' priority. The current directory is \emph{always} considered first. That is,
#' if a file \code{a.r} exists both in the current directory and in a module
#' search path, the local file \code{./a.r} will be loaded.
#'
#' Module names can be fully qualified to refer to nested paths. See
#' \code{Examples}.
#'
#' @note Unlike for packages, attaching happens \emph{locally}: if
#' \code{import} is executed in the global environment, the effect is the same.
#' Otherwise, the imported module is inserted as the parent of the current
#' \code{environment()}. When used (globally) \emph{inside} a module, the newly
#' imported module is only available inside the modules search path, not
#' outside it (nor in other modules which might be loaded).
#'
#' @examples
#' # `a.r` is a file in the local directory containing a function `f`.
#' a = import('a')
#' a$f()
#'
#' # b/c.r is a file in path `b`, containing a function `g`.
#' import('b/c', attach = TRUE)
#' g() # No module name qualification necessary
#'
#' @seealso \code{unload}
#' @seealso \code{reload}
#' @seealso \code{module_name}
#' @export
import = function (module, attach, attach_operators = TRUE) {
module = substitute(module)
stopifnot(inherits(module, 'name'))
if (missing(attach)) {
attach = if (interactive() && is.null(module_name()))
getOption('import.attach', FALSE)
else
FALSE
}
stopifnot(class(attach) == 'logical' && length(attach) == 1)
module_path = try(find_module(module), silent = TRUE)
if (inherits(module_path, 'try-error'))
stop(attr(module_path, 'condition')$message)
containing_modules = module_init_files(module, module_path)
mapply(do_import, names(containing_modules), containing_modules)
mod_ns = do_import(as.character(module), module_path)
module_parent = parent.frame()
mod_env = exhibit_namespace(mod_ns, as.character(module), module_parent)
if (attach) {
if (identical(module_parent, .GlobalEnv))
attach(mod_env, name = environmentName(mod_env))
else
parent.env(module_parent) = mod_env
}
else if (attach_operators)
export_operators(mod_ns, module_parent)
invisible(mod_env)
}
do_import = function (module_name, module_path) {
if (is_module_loaded(module_path))
return(get_loaded_module(module_path))
# The namespace contains a modules content. This schema is very much like
# R package organisation.
# A good resource for this is:
# <http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/>
namespace = structure(new.env(parent = .BaseNamespaceEnv),
name = paste('namespace', module_name, sep = ':'),
path = module_path,
class = c('namespace', 'environment'))
local(source(attr(environment(), 'path'), chdir = TRUE, local = TRUE),
envir = namespace)
cache_module(namespace)
namespace
}
exhibit_namespace = function (namespace, name, parent) {
exported_functions = lsf.str(namespace)
# Skip one parent environment because this module is hooked into the chain
# between the calling environment and its ancestor, thus sitting in its
# local object search path.
structure(list2env(sapply(exported_functions, get, envir = namespace),
parent = parent.env(parent)),
name = paste('module', name, sep = ':'),
path = module_path(namespace),
class = c('module', 'environment'))
}
export_operators = function (namespace, parent) {
# `$` cannot be overwritten, but it is generic so S3 variants of it can be
# defined. We therefore test it as well.
ops = c('+', '-', '*', '/', '^', '**', '&', '|', ':', '::', ':::', '$', '=',
'<-', '<<-', '==', '<', '<=', '>', '>=', '!=', '~', '&&', '||')
is_predefined = function (f) f %in% ops
is_op = function (f) {
prefix = strsplit(f, '\\.')[[1]][1]
is_predefined(prefix) || grepl('^%.*%$', prefix)
}
operators = Filter(is_op, lsf.str(namespace))
name = module_name(namespace)
# Skip one parent environment because this module is hooked into the chain
# between the calling environment and its ancestor, thus sitting in its
# local object search path.
op_env = structure(list2env(sapply(operators, get, envir = namespace),
parent = parent.env(parent)),
name = paste('operators', name, sep = ':'),
path = module_path(namespace),
class = c('module', 'environment'))
if (identical(parent, .GlobalEnv))
attach(op_env, name = environmentName(op_env))
else
parent.env(parent) = op_env
}
#' Unload a given module
#'
#' Unset the module variable that is being passed as a parameter, and remove the
#' loaded module from cache.
#' @param module reference to the module which should be unloaded
#' @note Any other references to the loaded modules remain unchanged, and will
#' still work. However, subsequently importing the module again will reload its
#' source files, which would not have happened without \code{unload}.
#' Unloading modules is primarily useful for testing during development, and
#' should not be used in production code.
#'
#' \code{unload} does not currently detach environments.
#' @seealso \code{import}
#' @seealso \code{reload}
#' @export
unload = function (module) {
stopifnot(inherits(module, 'module'))
module_ref = as.character(substitute(module))
rm(list = module_path(module), envir = .loaded_modules)
# unset the module reference in its scope, i.e. the callers environment or
# some parent thereof.
rm(list = module_ref, envir = parent.frame(), inherits = TRUE)
}
#' Reload a given module
#'
#' Remove the loaded module from the cache, forcing a reload. The newly reloaded
#' module is assigned to the module reference in the calling scope.
#' @param module reference to the module which should be unloaded
#' @note Any other references to the loaded modules remain unchanged, and will
#' still work. Reloading modules is primarily useful for testing during
#' development, and should not be used in production code.
#'
#' \code{reload} does not work correctly with attached environments.
#' @seealso \code{import}
#' @seealso \code{unload}
#' @export
reload = function (module) {
stopifnot(inherits(module, 'module'))
module_ref = as.character(substitute(module))
module_path = module_path(module)
module_name = module_name(module)
rm(list = module_path, envir = .loaded_modules)
#' @TODO Once we have `attach`, need also to take care of the search path
#' and whatnot.
mod_ns = do_import(module_name, module_path)
module_parent = parent.frame()
mod_env = exhibit_namespace(mod_ns, module_ref, module_parent)
assign(module_ref, mod_env, envir = module_parent, inherits = TRUE)
}

257
samples/Red/example.red Normal file
View File

@@ -0,0 +1,257 @@
Red [
Title: "Red console"
Author: ["Nenad Rakocevic" "Kaj de Vos"]
File: %console.red
Tabs: 4
Rights: "Copyright (C) 2012-2013 Nenad Rakocevic. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/dockimbel/Red/blob/master/BSL-License.txt
}
Purpose: "Just some code for testing Pygments colorizer"
Language: http://www.red-lang.org/
]
#system-global [
#either OS = 'Windows [
#import [
"kernel32.dll" stdcall [
AttachConsole: "AttachConsole" [
processID [integer!]
return: [integer!]
]
SetConsoleTitle: "SetConsoleTitleA" [
title [c-string!]
return: [integer!]
]
ReadConsole: "ReadConsoleA" [
consoleInput [integer!]
buffer [byte-ptr!]
charsToRead [integer!]
numberOfChars [int-ptr!]
inputControl [int-ptr!]
return: [integer!]
]
]
]
line-buffer-size: 16 * 1024
line-buffer: allocate line-buffer-size
][
#switch OS [
MacOSX [
#define ReadLine-library "libreadline.dylib"
]
#default [
#define ReadLine-library "libreadline.so.6"
#define History-library "libhistory.so.6"
]
]
#import [
ReadLine-library cdecl [
read-line: "readline" [ ; Read a line from the console.
prompt [c-string!]
return: [c-string!]
]
rl-bind-key: "rl_bind_key" [
key [integer!]
command [integer!]
return: [integer!]
]
rl-insert: "rl_insert" [
count [integer!]
key [integer!]
return: [integer!]
]
]
#if OS <> 'MacOSX [
History-library cdecl [
add-history: "add_history" [ ; Add line to the history.
line [c-string!]
]
]
]
]
rl-insert-wrapper: func [
[cdecl]
count [integer!]
key [integer!]
return: [integer!]
][
rl-insert count key
]
]
]
Windows?: system/platform = 'Windows
read-argument: routine [
/local
args [str-array!]
str [red-string!]
][
if system/args-count <> 2 [
SET_RETURN(none-value)
exit
]
args: system/args-list + 1 ;-- skip binary filename
str: simple-io/read-txt args/item
SET_RETURN(str)
]
init-console: routine [
str [string!]
/local
ret
][
#either OS = 'Windows [
;ret: AttachConsole -1
;if zero? ret [print-line "ReadConsole failed!" halt]
ret: SetConsoleTitle as c-string! string/rs-head str
if zero? ret [print-line "SetConsoleTitle failed!" halt]
][
rl-bind-key as-integer tab as-integer :rl-insert-wrapper
]
]
input: routine [
prompt [string!]
/local
len ret str buffer line
][
#either OS = 'Windows [
len: 0
print as c-string! string/rs-head prompt
ret: ReadConsole stdin line-buffer line-buffer-size :len null
if zero? ret [print-line "ReadConsole failed!" halt]
len: len + 1
line-buffer/len: null-byte
str: string/load as c-string! line-buffer len
][
line: read-line as c-string! string/rs-head prompt
if line = null [halt] ; EOF
#if OS <> 'MacOSX [add-history line]
str: string/load line 1 + length? line
; free as byte-ptr! line
]
SET_RETURN(str)
]
count-delimiters: function [
buffer [string!]
return: [block!]
][
list: copy [0 0]
c: none
foreach c buffer [
case [
escaped? [
escaped?: no
]
in-comment? [
switch c [
#"^/" [in-comment?: no]
]
]
'else [
switch c [
#"^^" [escaped?: yes]
#";" [if zero? list/2 [in-comment?: yes]]
#"[" [list/1: list/1 + 1]
#"]" [list/1: list/1 - 1]
#"{" [list/2: list/2 + 1]
#"}" [list/2: list/2 - 1]
]
]
]
]
list
]
do-console: function [][
buffer: make string! 10000
prompt: red-prompt: "red>> "
mode: 'mono
switch-mode: [
mode: case [
cnt/1 > 0 ['block]
cnt/2 > 0 ['string]
'else [
prompt: red-prompt
do eval
'mono
]
]
prompt: switch mode [
block ["[^-"]
string ["{^-"]
mono [red-prompt]
]
]
eval: [
code: load/all buffer
unless tail? code [
set/any 'result do code
unless unset? :result [
if 67 = length? result: mold/part :result 67 [ ;-- optimized for width = 72
clear back tail result
append result "..."
]
print ["==" result]
]
]
clear buffer
]
while [true][
unless tail? line: input prompt [
append buffer line
cnt: count-delimiters buffer
either Windows? [
remove skip tail buffer -2 ;-- clear extra CR (Windows)
][
append buffer lf ;-- Unix
]
switch mode [
block [if cnt/1 <= 0 [do switch-mode]]
string [if cnt/2 <= 0 [do switch-mode]]
mono [do either any [cnt/1 > 0 cnt/2 > 0][switch-mode][eval]]
]
]
]
]
q: :quit
if script: read-argument [
script: load script
either any [
script/1 <> 'Red
not block? script/2
][
print "*** Error: not a Red program!"
][
do skip script 2
]
quit
]
init-console "Red Console"
print {
-=== Red Console alpha version ===-
(only ASCII input supported)
}
do-console

124
samples/Red/example.reds Normal file
View File

@@ -0,0 +1,124 @@
Red/System [
Title: "Red/System example file"
Purpose: "Just some code for testing Pygments colorizer"
Language: http://www.red-lang.org/
]
#include %../common/FPU-configuration.reds
; C types
#define time! long!
#define clock! long!
date!: alias struct! [
second [integer!] ; 0-61 (60?)
minute [integer!] ; 0-59
hour [integer!] ; 0-23
day [integer!] ; 1-31
month [integer!] ; 0-11
year [integer!] ; Since 1900
weekday [integer!] ; 0-6 since Sunday
yearday [integer!] ; 0-365
daylight-saving-time? [integer!] ; Negative: unknown
]
#either OS = 'Windows [
#define clocks-per-second 1000
][
; CLOCKS_PER_SEC value for Syllable, Linux (XSI-conformant systems)
; TODO: check for other systems
#define clocks-per-second 1000'000
]
#import [LIBC-file cdecl [
; Error handling
form-error: "strerror" [ ; Return error description.
code [integer!]
return: [c-string!]
]
print-error: "perror" [ ; Print error to standard error output.
string [c-string!]
]
; Memory management
make: "calloc" [ ; Allocate zero-filled memory.
chunks [size!]
size [size!]
return: [binary!]
]
resize: "realloc" [ ; Resize memory allocation.
memory [binary!]
size [size!]
return: [binary!]
]
]
JVM!: alias struct! [
reserved0 [int-ptr!]
reserved1 [int-ptr!]
reserved2 [int-ptr!]
DestroyJavaVM [function! [[JNICALL] vm [JVM-ptr!] return: [jint!]]]
AttachCurrentThread [function! [[JNICALL] vm [JVM-ptr!] penv [struct! [p [int-ptr!]]] args [byte-ptr!] return: [jint!]]]
DetachCurrentThread [function! [[JNICALL] vm [JVM-ptr!] return: [jint!]]]
GetEnv [function! [[JNICALL] vm [JVM-ptr!] penv [struct! [p [int-ptr!]]] version [integer!] return: [jint!]]]
AttachCurrentThreadAsDaemon [function! [[JNICALL] vm [JVM-ptr!] penv [struct! [p [int-ptr!]]] args [byte-ptr!] return: [jint!]]]
]
;just some datatypes for testing:
#some-hash
10-1-2013
quit
;binary:
#{00FF0000}
#{00FF0000 FF000000}
#{00FF0000 FF000000} ;with tab instead of space
2#{00001111}
64#{/wAAAA==}
64#{/wAAA A==} ;with space inside
64#{/wAAA A==} ;with tab inside
;string with char
{bla ^(ff) foo}
{bla ^(( foo}
;some numbers:
12
1'000
1.2
FF00FF00h
;some tests of hexa number notation with not common ending
[ff00h ff00h] ff00h{} FFh"foo" 00h(1 + 2) (AEh)
;normal words:
foo char
;get-word
:foo
;lit-word:
'foo 'foo
to-integer foo
foo/(a + 1)/b
call/output reform ['which interpreter] path: copy ""
version-1.1: 00010001h
#if type = 'exe [
push system/stack/frame ;-- save previous frame pointer
system/stack/frame: system/stack/top ;-- @@ reposition frame pointer just after the catch flag
]
push CATCH_ALL ;-- exceptions root barrier
push 0 ;-- keep stack aligned on 64-bit

View File

@@ -306,6 +306,10 @@ class TestBlob < Test::Unit::TestCase
assert blob("public/javascripts/angular.js").vendored?
assert blob("public/javascripts/angular.min.js").vendored?
# D3.js
assert blob("public/javascripts/d3.v3.js").vendored?
assert blob("public/javascripts/d3.v3.min.js").vendored?
# Fabric
assert blob("fabfile.py").vendored?