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 [Description: "Some prime funcs"] | |
primes: function [n [integer!]][ | |
poke prim: make bitset! n 1 true | |
r: 2 while [r * r <= n][ | |
repeat q n / r - 1 [poke prim q + 1 * r true] | |
until [not pick prim r: r + 1] | |
] | |
collect [repeat i n [if not prim/:i [keep i]]] | |
] |
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
make-block: function [data /all /with selection [word! block!]][ | |
if word? selection [selection: to-block selection] | |
either any [ | |
accessors: select system/catalog/accessors type?/word data | |
system/words/all [ ; NB! Modifies global "query" | |
url? data | |
data: decode-url data | |
accessors: words-of data | |
] | |
system/words/all [ |
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 [ | |
Description: {Playing while reading Wikidata SPARQL tutorial} | |
See: https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial | |
Also: https://stackoverflow.com/questions/38527828/how-to-query-wikidata-items-using-its-labels | |
Needs: View | |
Also-needs: https://github.com/toomasv/table-template | |
] | |
#include %table-template.red | |
ws: charset " ^-^/" |
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 [] | |
move-faces: function [parent except inserted dim][ | |
anti: select [x y x] dim | |
win: parent/parent | |
max-size: 0x0 | |
last-size: parent/size | |
foreach-face/with parent [ | |
sz: either face/offset = except/offset [ | |
except/size/:dim + 10 |
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 [ | |
Description: "Spell out numbers" | |
] | |
context [ | |
digits: [One Two Three Four Five Six Seven Eight Nine] | |
tens: [_ Twenty Thirty Fourty Fifty Sixty Seventy Eighty Ninety] | |
teens: [Ten Eleven Twelve Thirteen Fourteen Fifteen Sixteen Seventeen Eighteen Nineteen] | |
orders: [Thousand Million Billion] | |
out: copy [] | |
res: copy [] |
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 [ | |
Description: "Puzzle" | |
See: "[June 22, 2022 9:56 PM](https://gitter.im/red/rethink?at=62b365e276cd751a2f507697)" | |
] | |
#include %to-num-word.red ;See next gist | |
prepare: func [puz] [ | |
count: 0 | |
total: length? reduce puzzle | |
clear res: [] | |
op: func [op /local f x][ |
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 [ | |
Needs: 'View | |
Problem: "[June 22, 2022 1:41 PM](https://gitter.im/red/red?at=62b2f1c8d3c8894f7198cf95)" | |
] | |
bind-part: function [what where with][ | |
yep: false | |
beg: where/1 | |
fin: where/2 | |
parse what [any [s: | |
if (s/1 = fin) thru end |
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 [ | |
Needs: 'View | |
License: "BSD-3" | |
] | |
;Mainly @hiiamboris | |
;Inserts closing `"])}` for `"[({` automatically | |
#system [ | |
#import [ | |
"user32.dll" stdcall [ | |
SendMessage: "SendMessageW" [ |
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 [ | |
Purpose: "Get overview of refinement usage" | |
Date: 15-Nov-2021 | |
Update: 4-Feb-2022 | |
Author: @toomasv | |
] | |
context [ | |
refs: make block! 100 | |
add-ref: func [ref fn][ | |
either got: refs/:ref [append got fn][repend refs [ref compose [(fn)]]] |
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 [ | |
Description: "Tic-Tac-Toe" | |
Date: 2021-02-26 | |
] | |
wins: [[1 2 3][4 5 6][7 8 9][1 4 7][2 5 8][3 6 9][1 5 9][3 5 7]] | |
check: func [move][ | |
foreach win wins [ | |
if 3 = length? intersect win state/:move [return win] | |
] |
NewerOlder