Skip to content

Instantly share code, notes, and snippets.

Toomas Vooglaid toomasv

View GitHub Profile
@toomasv
toomasv / bases-sig.red
Created Mar 30, 2019
Study of signed basis
View bases-sig.red
Red [
Author: "Toomas Vooglaid"
Date: 22-Mar-2019
Title: "Compare signed bases"
Purpose: {Introduction to study of signed number basis}
]
context [
set-bits: does [forall bits [pan/pane/(index? bits)/data: make logic! to-integer to-string bits/1]]
set-num: function [hx][
int: to-integer hx
@toomasv
toomasv / layout-demo.red
Created Mar 20, 2019
Layout adjustment demo
View layout-demo.red
Red []
context [
env: self
canvas: none
tab-pan: drawing-panel-tab: animations: none
info-panel: edit-options-panel: options-panel: drawing-panel: figs-panel: anim-panel: none
layer: layer1: drawing: selection-layer: grid-layer: drawing-layer: edit-layer: none
win: layout/options compose/deep [;
title "Drawing pad"
size 540x465
@toomasv
toomasv / basis.red
Last active Mar 19, 2019
Intro to study of number basis
View basis.red
Red [
Author: "Toomas Vooglaid"
Date: 19-Mar-2019
Title: "Compare bases"
Purpose: {Introduction to study of number basis}
]
context [
set-bits: does [forall bits [pan/pane/(index? bits)/data: make logic! to-integer to-string bits/1]]
hexa: charset [#"0" - #"9" #"A" - #"F"]
bit: pan: num: bin: bits: hex: bi: hx: none
@toomasv
toomasv / rtd-simple.red
Last active Mar 16, 2019
Simplified syntax for rich-text
View rtd-simple.red
Red [
Author: "Toomas Vooglaid"
Date: 9-Mar-2019
Purpose: {Simplified syntax for rich-text specification}
]
context [
format-word: no
format-any: copy []
in-string?: no
sp: charset " ^-"
@toomasv
toomasv / play.red
Last active Mar 6, 2019
Play beeps
View play.red
Red [
Needs: View
Author: "Gregg Irwin"
Porter: "Toomas Vooglaid"
Source: https://gitter.im/red/red/gui-branch?at=5c7f0f2e86e34a126f92a7be
Port-date: 6-Mar-2019
]
#system [
#import [
"kernel32.dll" stdcall [
@toomasv
toomasv / dbquery.red
Created Feb 28, 2019
Simple query dialect
View dbquery.red
Red [
Author: "Toomas Vooglaid"
Date: 2019-02-27
Challenge: https://gitter.im/red/help?at=5c75b4d7d2d62067b7101b03
File: %dbquery.red
Purpose: {Simple query dialect}
TBD: {change delete}
]
;@GiuseppeChillemi [February 26, 2019 11:51 PM](https://gitter.im/red/help?at=5c75b4d7d2d62067b7101b03)
assign: func [words values][
@toomasv
toomasv / drop-to-list.red
Created Feb 13, 2019
Drag words from area to text-list experiment
View drop-to-list.red
Red [
Author: "Toomas Vooglaid"
Date: 13-Feb-2019
Purpose: {Example of dragging words from area to text-list}
]
count-nl: func [face /local text n x][
n: 0 x: face/selected/x
text: copy face/text
while [all [
text: find/tail text #"^/"
@toomasv
toomasv / syntax.rtd
Created Jan 14, 2019
Study of syntax highlighting
View syntax.rtd
Red [
Author: "Toomas Vooglaid"
Date: 2019-01-14
Purpose: {Study of syntax highlighting}
]
skp: charset " ^/^-[]()/"
initial-size: 800x800
addr: func [s1 s2 style] bind [keep as-pair i: index? s1 (index? s2) - i keep style] :collect
rule: [any [s:
skp
@toomasv
toomasv / lcs.red
Last active Mar 16, 2019
Longest Common Subsequence
View lcs.red
Red [
Purpose: "Longest Common Subsequence"
Partially-based-on: http://rosettacode.org/wiki/Longest_common_subsequence
Date: 8-Jan-2019
Last: 10-Jan-2019
]
lcs: function [s t][
case [ ; preliminary checks
s = t [return copy s]
any [empty? s empty? t] [return copy ""]
@toomasv
toomasv / levenshtein.red
Last active Mar 16, 2019
Implementation of Levenshtein distance
View levenshtein.red
Red [
Date: 6-Jan-2019
File: %levenshtein.red
]
lev: function [s t][
unless string? s [s: mold s]
unless string? t [t: mold t]
case [
s = t [return 0]
empty? s [return (length? t)]
You can’t perform that action at this time.