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
REBOL [] | |
math: context [ | |
eps: 1E-15 | |
steps: 0 | |
math-init: func [] [ | |
steps: 0 | |
] |
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
REBOL [] | |
switch fourth system/version [ | |
3 [ | |
curses: make library! %pdcurses.dll | |
kernel32: make library! %kernel32.dll | |
alloc-console: make routine! compose [ | |
[ | |
return: [int32] |
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
! Copyright (C) 2015 Your name. | |
! See http://factorcode.org/license.txt for BSD license. | |
USING: kernel ui.gadgets ui.render ui.gadgets.worlds opengl opengl.gl colors ; | |
IN: draw-ex | |
TUPLE: canv < gadget ; | |
: <canv> ( -- gadget ) canv new ; | |
M: canv draw-gadget* ( gadget -- ) |
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
proc invariant {var {expression ""} {msg "Illegal value"}} { | |
uplevel trace variable $var w \ | |
\[list invariant_check \{$expression\} \{$msg\}] | |
} | |
proc invariant_check {expression msg v1 v2 mode} { | |
if {$expression == ""} { | |
error "Cannot modify!" | |
} | |
if {![uplevel expr \{$expression\}]} { |
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
(define-macro (define-c-constant name #!optional (type 'int) (new-name name)) | |
`(define ,new-name | |
`,((c-lambda | |
() ,type | |
,(string-append "___result = " (symbol->string name) ";"))))) |
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
# We need it for serious work | |
package require Tk 8.6 | |
# We need it for fun | |
package require snack | |
package require snackogg | |
# Gas constant | |
set R 8.3144621 | |
########################################################################### |
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
NB. pretty stubby librsvg bindings | |
coclass 'jrsvg' | |
NB. define unnamed monad and call it in-place | |
NB. verb wrapping is needed for control structures | |
NB. as they work only within explicit definitions | |
monad define'' | |
select. UNAME | |
case. 'Linux' do. | |
librsvg=:<'librsvg-2.so.2' |
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
;; Differential evolution minimization algorithm | |
;; | |
;; f -- minimized function | |
;; feasible? -- predicate for checking feasibility of a vector | |
;; initial-population | |
;; F -- value in v1 + F(v2 - v3). Must be in [0..2] | |
;; CR -- probability of crossing in crossover | |
;; generations -- maximal number of generations | |
(define (differential-evolution f feasible? initial-population F CR generations) | |
;; Auxiliary function breed |
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
(define (identity n) | |
(letrec | |
((uvec | |
(lambda (m i acc) | |
(if (= i n) | |
acc | |
(uvec m (+ i 1) | |
(cons (if (= i m) 1 0) acc))))) | |
(idgen | |
(lambda (i acc) |
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
;======================================================================= | |
; an x86 bootsector implementation of | |
; 99 bottles of beer | |
; by Ivan Sukin <isukin.intelliware@gmail.com> | |
; based on template made by shoorick | |
;======================================================================= | |
;======================================================================= | |
; Drive info | |
;======================================================================= |
NewerOlder