Skip to content

Instantly share code, notes, and snippets.

View endo64's full-sized avatar
🏠

Semseddin Moldibi endo64

🏠
View GitHub Profile
@toomasv
toomasv / check.red
Last active March 16, 2019 22:25
Checking for matching/closing of nested thing and strings
Red []
ctx: context [
char: charset {([{}])"} ;"
opens: charset "[("
closes: charset "])"
line: 1
stack: make block! 1000
mark: comm: none
instr: false
inmulti: 0
@meijeru
meijeru / check-structure.red
Last active February 1, 2019 16:22
Check if brackets/parens are matching in a Red source and give errors with indication of line number
Red [
Title: "Red program structure checker"
Purpose: {Check if brackets/parens are matching in a Red file
and give errors with indication of line number}
Author: "Rudolf W. MEIJER"
File: %check-structure.red
History: [
[0.0 04-Jan-2019 {Start of project}]
[0.5 05-Jan-2019 {First working version}]
[0.6 01-Feb-2019 {Added %" "}]
@toomasv
toomasv / multi-selection-text-list.red
Last active August 11, 2018 19:24
Multi-selection text-list
Red [
Author: "Toomas Vooglaid"
Date: 2018-08-10
Last: 2018-08-11
Purpose: {Attempt at multi-selection text-list style}
]
cnt: 0
view [
style multi-selection-text-list: text-list
on-create [face/extra: object [key: none selected: none selection: copy [] nums: copy [] layer: none]]
@giesse
giesse / profile-gab.red
Last active November 20, 2021 19:13
profile function for Red (two variants)
Red []
e.g.: :comment
; ideally not exported on the global context
delta-time*: function [code count] [
start: now/precise
loop count code
difference now/precise start
]
@toomasv
toomasv / conversion-lab.red
Last active May 9, 2018 10:55
Experiment with conversions
Red [
Needs: View
Author: "Toomas Vooglaid"
Date: 2018-01-12
Purpose: {To study conversions between datatypes}
]
ctx: context [
types: compose [
hex #00000001
local-file "file.red"
@greggirwin
greggirwin / profile.red
Last active December 28, 2020 06:17
Basic profiling for Red code comparisons
Red []
e.g.: :comment
delta-time: function [
"Return the time it takes to evaluate a block"
code [block! word! function!] "Code to evaluate"
/count ct "Eval the code this many times, rather than once"
][
ct: any [ct 1]
@dockimbel
dockimbel / parse-info.red
Last active October 24, 2017 08:46
Function to get stats about internal parse states usage for a given parsing job.
Red [
Title: "Parse Info"
Purpose: {
Provides some stats about internal parse states usage for a given parsing job.
Could be used as a way to compare efficiency of different parsing strategies.
}
Date: 06-Oct-2017
]
context [
@dander
dander / generators.red
Last active August 27, 2020 07:29
An experiment to make a general purpose generator-creating function
Red [
Title: "generator function experiments"
Author: "Dave Andersen"
Date: 27-Sep-2017
]
reload: does [do system/options/script]
; @JacobGood's closure func
closure1: func [
@greggirwin
greggirwin / red-object-browser.red
Last active October 16, 2020 17:48
Red Object Browser
Red [
title: "Red Object Browser"
author: "Gregg Irwin"
needs: 'View
]
e.g.: :comment
map-ex: func [
"Evaluates a function for all values in a series and returns the results."
@toomasv
toomasv / dir-tree.red
Last active January 6, 2022 11:30
Print a directory tree
Red [
Author: "Toomas Vooglaid"
Date: "2017-05-07"
Changed: "2018-07-09"
Purpose: "Print a directory tree"
File: "%dir-tree.red"
]
context [
; Some helpers
get-char: func [hex][to-char to-integer hex]