Skip to content

Instantly share code, notes, and snippets.

Avatar

Toomas Vooglaid toomasv

View GitHub Profile
View simple-pie.red
Red [
Description: "Simple pie chart"
File: %simple-pie.red
Author: "Toomas Vooglaid"
Original: https://gitter.im/red/help?at=5b4f23adecc1f82e2fc206d6
Date: 18-Jul-2020
Adaptation: 14-Nov-2020
]
start: -90
tx: make-face 'text
@toomasv
toomasv / replace.red
Last active Sep 25, 2020
`replace` extended with `/only` refinement
View replace.red
Red [
Description: "`replace` extended with `/only` refinement"
Date: 24-Sep-2020
]
replace: func ["Replaces values in a series, in place"
series [series!] "The series to be modified"
pattern "Specific value or parse rule pattern to match"
value "New value, replaces pattern in the series"
/all "Replace all occurrences, not just the first"
/deep "Replace pattern in all sub-lists as well"
@toomasv
toomasv / quiz.red
Created Sep 21, 2020
Quiz about capitals
View quiz.red
Red []
page: read-thru/binary https://geographyfieldwork.com/WorldCapitalCities.htm
quiz: does [
capitals: clear []
loop 5 [
list: head page
loop (random 200) - 1 [
l: find list <td height="17"> list: find l </tr>
]
parse to-string copy/part l: find list <td height="17"> list: find l </tr> [
@toomasv
toomasv / hangman.red
Last active Jul 31, 2020
wallysilva's hangman modified
View hangman.red
Red [
Title: "The Hangman Game"
Date: "21-Jul-2020"
Author: Wally Silva
File: %hangman.red
Needs: View
Original: https://github.com/wallysilva/red-hangman
Modified: {toomasv on 31-Jul-2020}
Tab: 4
]
@toomasv
toomasv / draw-table.red
Last active Jun 28, 2020
Experiment with draw-based table
View draw-table.red
Red [
Description: "Simple navigation for draw-based table"
]
recycle/off
len-data: 200'000;0
data: make block! len-data
rows: 30
cols: 11
bx: 100x24
current: none
@toomasv
toomasv / intermediate.red
Last active Jun 12, 2020
Sow integmediate values of expression in console
View intermediate.red
Red [
Description: "Show values of intermediate expressions"
Date: 12-Jun-2020
]
term: gui-console-ctx/terminal
show: function [][
out2: copy [] out: pos: copy []
found: find/tail term/line "show "
@toomasv
toomasv / range-pre-load.red
Last active Jun 23, 2020
Mimick range and bound syntax
View range-pre-load.red
Red [
Description: "Pre-load to mimic range/bounds syntax"
Date: 22-May-2020
Author: @toomasv
]
context [
default-start: func [stop step][
case [
any [percent? stop percent? :step][1%]
any [pair? stop pair? :step][1x1]
@toomasv
toomasv / range-ops.red
Last active May 24, 2020
Range and step ops
View range-ops.red
Red [
Description: "Some range and step ops"
Date: 21-May-2020
]
;Simple range op!
;works when a < b and with integer! and date! only
..: make op! func [a [integer! date!] b [integer! date!] /local i out][
out: copy [] repeat i b - a + 1 [append out i - 1 + a]
]
@toomasv
toomasv / replace-each.red
Last active Apr 13, 2020
Replace several items in one run + example converters
View replace-each.red
Red [
Description: {Replace several items in one run + example conversions}
Date: 27-Mar-2020
Author: "Toomas Vooglaid"
]
context [
sp: charset " ^-"
sp*: [any sp]
digit: charset "0123456789"
integer: [some digit]
@toomasv
toomasv / compare.red
Last active Mar 25, 2020
Return relation of provided arguments
View compare.red
Red [
Description: {Return relation of provided arguments}
Date: 25-Mar-2020
Author: "Tooams Vooglaid"
]
compare: function [
"Compare arguments and return their relation"
a [any-type!]
b [any-type!]
/length "Compare length of arguments"
You can’t perform that action at this time.