Skip to content

Instantly share code, notes, and snippets.

View endo64's full-sized avatar
🏠

Semseddin Moldibi endo64

🏠
View GitHub Profile
b: []
;== []
v1: ["a" "B"]
;== ["a" "B"]
v2: ["A" "b"]
;== ["A" "b"]
alter b v1 b
;== [["a" "B"]]
Red [
Title: {Request a date}
Purpose: {To enter a date using a calendar display}
Author: "Rudolf W. MEIJER"
File: %request-date.red
Notes: {Inspired by the corresponding Rebgui facility}
Language: 'English
Tabs: 4
] ; end prologue
@endo64
endo64 / forach-face-continue
Last active March 16, 2019 21:59
CONTINUE support for FOREACH-FACE function
foreach-face: func [{Evaluates body for each face in a face tree matching the condition}
face [object!] "Root face of the face tree"
body [block! function!] {Body block (`face` object) or function `func [face [object!]]`}
/with "Filter faces according to a condition"
spec [block! none!] "Condition applied to face object"
/post {Evaluates body for current face after processing its children}
/sub post? "Do not rebind body and spec, internal use only"
/local exec continue ; <-- addition #0
][
unless block? face/pane [exit]
Red [
title: "Loads an INI file and returns a map!"
notes: "semi-colons treats as comment"
]
load-ini: function [ini [file! string!]] [
m: copy #()
if file? ini [ini: read ini]
parse ini [some [copy word to "=" skip copy value to [";" | newline | end] pos: (
if #";" = pos/1 [
unless pos: find pos newline [pos: tail ini]
@endo64
endo64 / sum.red
Last active August 9, 2018 22:49
Sum function for Red
Red []
do %profile.red
sum1: func [
"Return sum of numbers in a block" b /safe "Coerce to return float in case of overflow" /local s v
] [
s: 0
foreach v b [
@endo64
endo64 / Refinements.red
Created July 27, 2018 23:17
Find functions with missing doc for their refinements
Red [
Title: "Find functions with missing doc for their refinements"
Date: 2018-07-28
Author: "Endo"
License: "MIT"
File: %Refinements.red
]
;find all natives, op, functions, actions that have refinement(s)
remove-each word words: words-of system/words [
@endo64
endo64 / profile.red
Created November 22, 2017 21:39 — forked from greggirwin/profile.red
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]