(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
// | |
// Operators.swift | |
// FastParsing | |
// | |
// Created by Chris Eidhof on 26/12/2016. | |
// Copyright © 2016 objc.io. All rights reserved. | |
// | |
// TODO: give appropriate credit. Many parts were stolen from SwiftParsec. |
// [Rust で 言語処理100本ノック 第1章 前半 - 僕とコードとブルーハワイ](http://equal-001.hatenablog.com/entry/2016/12/14/232933) | |
// にコメントフォームがなかったのでコードぶん投げます | |
//# 00. 文字列の逆順 | |
//文字列"stressed"の文字を逆に(末尾から先頭に向かって)並べた文字列を得よ. | |
fn no_00() -> String { | |
let s = "stressed"; | |
s.chars() | |
.rev() | |
// 型を入れないとエラーになるのはcollectがジェネリックなため、推論出来ないから。 |
use std::rc::Rc; | |
trait HKT<U> { | |
type C; // Current type | |
type T; // Type with C swapped with U | |
} | |
macro_rules! derive_hkt { | |
($t:ident) => { | |
impl<T, U> HKT<U> for $t<T> { |
/// See | |
/// https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift | |
/// https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c | |
/// to find why this works | |
func peekFunc<A,R>(f:A->R)->(fp:Int, ctx:Int) { | |
let (hi, lo):(Int, Int) = reinterpretCast(f) | |
let offset = sizeof(Int) == 8 ? 16 : 12 | |
let ptr = UnsafePointer<Int>(lo+offset) | |
return (ptr.memory, ptr.successor().memory) | |
} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# YOU NEED TO INSERT YOUR APP KEY AND SECRET BELOW! | |
# Go to dropbox.com/developers/apps to create an app. | |
app_key = 'YOUR_APP_KEY' | |
app_secret = 'YOUR_APP_SECRET' | |
# access_type can be 'app_folder' or 'dropbox', depending on | |
# how you registered your app. | |
access_type = 'app_folder' |