This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
start-url: http://exam.com | |
done-file: %done.txt | |
storage: %strore.txt | |
done-urls: attempt [ read/lines done-file ] | |
urls: copy [] | |
get-a: func [ url [ url! ] /local rule data s] [ | |
rule: [ while [ thru "<a" thru "href=" skip copy s to [{"} | {'} ] | |
(if all [find [ %.htm %.html] suffix? s not find urls s not find done-urls s find/match s "http"] [ append urls to-url s ] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
factorial: func [ n [ integer! ]][ | |
factorial-util n 1 | |
] | |
factorial-util: func [ n [ integer! ] init [ integer! ]][ | |
if any [ n = 0 n = 1] [ return init ] | |
return factorial-util n - 1 init * n | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [ | |
title: "A Tic Tac Toe Game to play with a clever computer." | |
] | |
tic-tac-toe: context [ | |
keypoints: [[ 1 2 3 ] [ 4 5 6 ] [ 7 8 9 ] [ 1 4 7 ] [ 2 5 8 ][ 3 6 9 ] [ 1 5 9 ][ 3 5 7 ]] | |
center: 5 | |
corners: [ 1 3 7 9 ] | |
sides: [ 2 4 6 8 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
blk: [a b c d] | |
indexes: [1 3] | |
result: collect [ | |
foreach index indexes [ | |
keep blk/:index | |
] | |
] | |
probe result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
dialect: [ 3 space 1 asterisk 3 space lf | |
2 space 3 asterisk 2 space lf | |
1 space 2 asterisk 1 star 1 asterisk lf | |
1 star 1 asterisk 1 star 3 asterisk lf | |
2 space 3 asterisk 2 space lf | |
1 space 2 asterisk 1 star 1 asterisk 1 space lf | |
7 asterisk lf | |
3 space 1 bar 3 space lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
str: "<Ids></Ids><Names></Names><Ids>99</Ids><Names>bar</Names>" | |
rule-1: [ | |
some [ | |
thru "<Ids>" insert "01" [ "</Ids>" | insert "," ] | |
thru "<Names>" insert "foo" [ "</Names>" | insert ","] | |
] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
data: [1 2 3 4 "a" "b" "c" "d"] | |
output: make block! length? data | |
foreach [p1 p2 p3 p4] data [ output: reduce/into [p1 p3 p4] output ] | |
probe head output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> type? f: func[][print "foo"] | |
== function! | |
>> type? get 'f | |
== function! | |
>> type? f | |
"foo" | |
== unset! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: {remove comments from JS source files} | |
Author: "Cui Wen" | |
File: %comment-cleaner.reb | |
Version: 0.1.0 | |
Tabs: 4 | |
] | |
data: { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rebol [ | |
Title: "Parse file uploads data by HTTP" | |
Author: "Cui Wen" | |
Description: { | |
simulate file-uploading via curl: | |
curl --form upload=@D:/a.txt --form upload=@D:/a.jpg --form press=OK http://localhost:8080 | |
} | |
] | |
server: open tcp://:8080 |
OlderNewer