Skip to content

Instantly share code, notes, and snippets.

Toomas Vooglaid toomasv

Block or report user

Report or block toomasv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@toomasv
toomasv / gen-hack2.red
Last active Aug 17, 2019
(de)randomize argument
View gen-hack2.red
Red [
Date: 16-Aug-2019
See: {[August 15, 2019 9:56 PM](https://gitter.im/red/red?at=5d55aacd4e17537f5239de0c) forward}
Description: {Combined from @grggirwin's and @dockimbel's with some spice}
]
gen-hack2: function [
{Generates randomly suffled copy of the argument and the seed to get it stright}
secret [any-string! any-block! binary!]
][
random/seed stats
@toomasv
toomasv / shooting.red
Last active Aug 14, 2019
Parametrized curve
View shooting.red
Red [
Title: "Shooting"
Description: "Exercise with parametrized curve"
Date: 2019-08-10
Author: "Toomas Vooglaid"
Licence: "Public domain"
Usage: {
To load and orient the weapon - drag point.
To relocate the target - drag target.
To relocate weapon - ctrl-drag it (cannon relocates horizontally on dragging).
@toomasv
toomasv / prisoners.red
Last active Aug 4, 2019
Prisoner's dilemma tournament
View prisoners.red
Red [
Description: "Prisoner's dilemma tournament"
Date: 3-Aug-2019
Author: "Toomas Vooglaid"
Licence: "Public domain"
]
;set [R P T S] [-1 -3 0 -6] ; One turn (original)
set [R P T S] [3 1 5 0]
choose: func [A B][reduce case [
all [A B] [[R R]] ;A and B [[R R]]
@toomasv
toomasv / fly.red
Last active Jul 30, 2019
Spider and fly
View fly.red
Red [
Date: 28-July-2019
Notes: {Click on window to add flies}
]
bb: [] fc: target: none
web: load %web.png
set-step: func [face][as-pair
face/extra/speed * (cosine face/extra/dir)
face/extra/speed * (sine face/extra/dir)
]
@toomasv
toomasv / rays.red
Last active Aug 2, 2019
Ray-casting exercise
View rays.red
Red [
Description: {Ray casting exercise}
Needs: View
Date: 25-July-2019
Inspiration: https://github.com/krisajenkins/elm-rays
Tutorial: https://ncase.me/sight-and-light/
Redporter: "Toomas Vooglaid"
Licence: "Public domain"
]
; To change into plain light instead of radial
@toomasv
toomasv / drag-to-panel.red
Created Jul 14, 2019
Drag and drop base into panel, dbl-click to get it out
View drag-to-panel.red
Red [
Description: {Dragn'drop into panel}
Date: 14-July-2019
]
context [
hop: false
pan: pane: ofs: none
view [
base loose
on-down [move find pane: face/parent/pane face tail pane]
@toomasv
toomasv / array-diagram
Last active Jul 10, 2019
diagram-style tryout
View array-diagram
Red [
Title: "Array func diagram"
Date: 9-Jul-2019
Needs: View
Author: "Toomas Vooglaid"
Uses: https://github.com/toomasv/diagram/blob/master/diagram-style.red
]
do %diagram-style.red
view dia [
title "Gregg's array func"
@toomasv
toomasv / includes.red
Created Jul 6, 2019
Check containment in series
View includes.red
Red [
Date: 2019-07-06
Author: "Toomas Vooglaid"
Motivation: https://gitter.im/red/help?at=5d20178fc5f3c329aef31f43
]
includes?: func [
"Check if first argument contains any of second argument"
a [series!]
b [any-type!]
][
View mget.red
Red [
Description: {Attempt to implement @GiuseppeChillemi's "path dialect"}
Date: 22-Jun-2019
Author: "Toomas Vooglaid"
]
system/lexer/pre-load: func [src][
chr: complement charset {/[ "#}
path: [some chr #"/" some chr]
mpath: [path change #"[" "/(" to #"]" change skip #")" any [#"/" mpath]]
@toomasv
toomasv / chess.red
Last active Jun 20, 2019
Play chess against yourself
View chess.red
Red [
Title: "Chess"
Author: "Toomas Vooglaid"
Date: 20-Jun-2019
]
glass: 0.0.0.216
chessboard: [origin 0x0 space 0x0]
repeat i 8 [loop 4 [append chessboard pick [[b w][w b]] even? i]]
You can’t perform that action at this time.