Skip to content

Instantly share code, notes, and snippets.

View rssh's full-sized avatar

Ruslan Shevchenko rssh

View GitHub Profile
@rssh
rssh / type aliases not substitied
Last active December 23, 2015 05:29
type arguments are not substited in macroses defined inside type provider: https://issues.scala-lang.org/browse/SI-7849
import org.scalatest._
import x._
import language.experimental.macros
class TieSpec extends FlatSpec {
"X" should "substitute macro argument" in {
val x = X.xProvider;
val a = new Arg[Int] {}
@rssh
rssh / gist:6908116
Created October 9, 2013 20:50
Romeo & Julietta. twitter style. Shakespeare ?
j: lol where r u romeo
r: wana come over?
j: cant
r: y?
j: idk parents
r: lets kill ourself
j: lol k
r: swag
j: swag
@rssh
rssh / OSDN_2013_2
Created October 9, 2013 21:15
Example on some program in C
int n = 10;
int s = 0;
for(int x = 1; x < n; ++x) {
s+=x;
}
@rssh
rssh / OSDN2013_3_vars
Created October 9, 2013 21:55
simle program, where variable names changes to undescore. (illustration for article)
int _ = 10;
int _ = 0;
for(int _ = 1; _ < _; ++x) {
_ += _;
}
@rssh
rssh / OSSN2013_4_forth1
Created October 9, 2013 22:03
Example of expression on forth language
0 10 1 DO i + LOOP;
@rssh
rssh / OSDN2013_Forth_5
Created October 10, 2013 05:57
example of getting square root in forth
: sqrt-closer (square guess -- square guess adjustment) 2dup / over - 2 / ;
: sqrt ( square -- root ) 1 begin sqrt-closer dup while + repeat drop nip ;
int x = 1
int d = 1
while(d != 0) {
d = (s/x - x)/2
x = x+d
}
@rssh
rssh / OSDN_7_rewriting
Created October 10, 2013 08:44
example of rewriting rules
sqrtd(s,x,0) -> x
sqrtd(s,x,d) -> sqrt(s, x+d, (s/x - x)/2 )
sqrt(s) -> sqrtd(s,1,(s-1)/2)
@rssh
rssh / OSDN_8_tcl
Created October 10, 2013 09:50
example of tcl expression with 'own' do-while
set x 1
do {
set d [expr ($s/$x - $x)/2]
while { $d != 0 }
@rssh
rssh / OSDN2013_8_tcl
Last active December 25, 2015 04:19
Implementation fo do/wile in tcl (fragment)
proc do {body whileword condition} {
global errorInfor errorCode
if {![string equal $whileword while]} {
error "should be \"do body while condition\""
}
while {1} {
set code [catch {uplevel 1 $body} message]
if { !ok( $code) } {
return handleBreak($code, $body, $message)
}