Skip to content

Instantly share code, notes, and snippets.

View draegtun's full-sized avatar

Barry Walsh draegtun

View GitHub Profile
@draegtun
draegtun / rebol.vim
Created April 27, 2017 08:28
Rebol VIM syntax file
" Vim syntax file
" Language: Rebol
" Maintainer: Mike Williams <mrw@netcomuk.co.uk>
" Filenames: *.r
" Last Change: 2001 May 09
" URL: N/A
" Changes-by: Barry Walsh <draegtun@gmail.com>
" Last updated: 17-May-2013
@draegtun
draegtun / challenge-304-accounts.reb
Created March 1, 2017 16:19
Reddit DailyProgrammer - "Little Accountant"
Rebol [
see: https://www.reddit.com/r/dailyprogrammer/comments/5wnbsi/20170228_challenge_304_easy_little_accountant/
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Helper functions
tie: function [s delim /string] [
s: next s
forskip s 2 [insert s delim]
@draegtun
draegtun / rebocalc.rebol
Created November 13, 2013 19:05
Spreadsheet in Rebol2 by Carl Sassenrath - http://www.rebol.org/view-script.r?script=rebocalc.r - Replicated here for nicer syntax highlighting
REBOL [
Title: "Rebocalc"
Date: 19-Jun-2001
Version: 1.0.0
File: %rebocalc.r
Author: "Carl Sassenrath"
Purpose: {The world's smallest spreadsheet program, but very powerful.}
Email: %carl--rebol--com
library: [
level: 'beginner
Rebol [
see: https://www.reddit.com/r/dailyprogrammer/comments/5go843/20161205_challenge_294_easy_rack_management_1/
]
scrabble: function [rack word] [
rack: reverse sort copy rack
score: 0
score-and-remove: func [s] [
score: score + score-letter s/1
@draegtun
draegtun / door.reb
Created March 30, 2016 18:39
Door challenge in Rebol
Rebol [
see: https://www.reddit.com/r/dailyprogrammer/comments/4cb7eh/20160328_challenge_260_easy_garage_door_opener/
]
states: [
'CLOSED [click: 'OPENING blocked: '*CLOSED]
'OPENING [click: 'STOPPED_WHILE_OPENING complete: 'OPEN blocked: '*OPENING]
'OPEN [click: 'CLOSING blocked: 'OPEN_BLOCKED]
'CLOSING [click: 'STOPPED_WHILE_CLOSING complete: 'CLOSED blocked: 'EMERGENCY_OPENING]
'STOPPED_WHILE_OPENING [click: 'CLOSING blocked: '*STOPPED_WHILE_OPENING]
@draegtun
draegtun / comma1.r3
Created January 15, 2014 15:48
Some comma quibbling in Rebol
Rebol []
comma-quibbling: func [block] [
rejoin [
"^{"
to-string use [s] [
s: copy block
s: next s
forskip s 2 [insert s either tail? next s [" and "] [", "]]
@draegtun
draegtun / remove-last.r3
Last active December 21, 2015 03:39
What I would like to see REMOVE/LAST do.
Rebol []
; see - http://stackoverflow.com/questions/18231434/in-a-series-what-is-the-best-way-of-removing-the-last-element
remove-last: func [
"Removes value(s) from tail of a series."
series [series! port! bitset! none!]
/part range [number!] "Removes to a given length."
][
either part [take/last/part series range] [take/last series]
Rebol []
; PHP
; $string = preg_replace( '/^@(.*?)@$/', '#$1#', $string );
;
; Perl
; $string =~ s/^\@(.*?)\@$/#$1#/;
;
; # or...
; $string =~ s/\A\@(.*?)\@\Z/#$1#/;
Rebol [
see-gist: https://gist.github.com/miyagawa/5455942
also-this: https://gist.github.com/shanselman/5422230#comment-823247
comment: "My fledgling Rebol port of this Perl code"
requires: "Rebol/View - for https:// port"
github-support: "Thank you Austin@Github for (initiating) the fix for Rebol syntax highlighting"
]
split-string: func [text delim /local s coll] [
coll: copy []
@draegtun
draegtun / select.r2
Last active December 16, 2015 07:59
Simple Rebol dialect example.
REBOL [
Purpose: "Providing Rebol example of a Lisp macro given in HN comment"
HNcomment: https://news.ycombinator.com/item?id=5482124
usage: "select [word-value from collection-list]"
]
select: func [block /local totals] [
parse block [
set this word!
'from