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 sys | |
# | |
# ParserInput | |
# | |
# This class represents the input data and the current | |
# position in the data. | |
# | |
# Brief note about 'max_position': |
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 operator | |
import itertools | |
def merge_key_with(f, k, dicts) : | |
if all((k in d) for d in dicts) : | |
return f(*(d[k] for d in dicts)) | |
else : | |
first = next(itertools.ifilter(lambda d : k in d, dicts)) | |
return first[k] |
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
# | |
# Program to convert infix expressions to postfix. | |
# It supports the following operators: | |
# - Addition ("+") | |
# - Multiplication ("*") | |
# - Logarithm ("L") | |
# | |
# Single digit values are supported. | |
# Lower-case alphabets are considered as variables. | |
# |
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
^\0 swift 0x000000010744f4eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43 | |
1 swift 0x000000010744e7d6 llvm::sys::RunSignalHandlers() + 70 | |
2 swift 0x000000010744fb4f SignalHandler(int) + 287 | |
3 libsystem_platform.dylib 0x00007fff8cfc152a _sigtramp + 26 | |
4 libsystem_platform.dylib 000000000000000000 _sigtramp + 1929636592 | |
5 swift 0x00000001052bc95c swift::irgen::SingleScalarTypeInfo<(anonymous namespace)::PrimitiveTypeInfo, swift::irgen::LoadableTypeInfo>::unpackFromEnumPayload(swift::irgen::IRGenFunction&, swift::irgen::EnumPayload const&, swift::irgen::Explosion&, unsigned int) const + 28 | |
6 swift 0x00000001052af4f9 swift::irgen::RecordTypeInfo<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::unpackFromEnumPayload(swift::irgen::IRGenFunction&, swift::irgen::EnumPayload const&, swift::irgen::Explosion&, unsigned int) const + 89 | |
7 |
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
// | |
// Helpers | |
// | |
import Foundation; | |
func bytesToNSData(a:[UInt8]) -> NSData { | |
return NSData(bytes:a, length:a.count); | |
} |
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
class A { | |
var values:[Int] = []; | |
} | |
func append1(inout a:A) { | |
let n = a.values.count; | |
a.values.append(n); | |
} | |
func append2(inout a:A) { |
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
func testAlias(inout a:(Int, Int), inout _ b:Int) { | |
print((a, b)); | |
} | |
var v = (10, 20); | |
testAlias(&v, &v.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
func test1(inout v:[Int], inout _ x:Int) { | |
v[0] += 1; | |
x += 1; | |
} | |
func test2(inout v:[Int], inout _ x:Int) { | |
v[0] += 1; | |
v.append(20); | |
x += 1; | |
} |
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
Modeling C Ambiguity. |
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
/* | |
This program triggers a bug in Clang when compiling with optimizations. | |
When compiling with no-optimizations, the correct output is produced. | |
$ clang -O0 test-bug.c && ./a.out | |
value = 1 | |
OlderNewer