object [
main: [(res: 0 clear stack) struct collect keep (round/to res .001)]
stack: copy []
res: 0
unit: ["*" (res: res + 1)]
exponent: ["(" (insert stack res res: 0) struct ")" (res: (exp res) + take stack)]
ln: ["[" (insert stack res res: 0) struct "]" (res: (log-e res) + take stack)]
invert: ["<" (insert stack res res: 0) struct ">" (res: 0 - res + take stack)]
struct: [any [
exponent | ln | invert | unit | " "
]]
set 'bmath does [
while ["" <> formula: input][
print parse formula main
]
]
]>> bmath *** 3.0 *** **** 7.0 ******* <***> 4.0 ([**][***]) 6.0 ([**** ****]<[**]>) 4.0 ([*****]<[**]>) 2.5 (([[**]][***])) 8.0 (([[*********]]<[**]>)) 3.0 (([[([********][**])]]<[**]>)) 4.0
>> print rejoin [greek "Hi there!" newline fr "Check it out."] Ηι θερε! ℭ𝔥𝔢𝔠𝔨 𝔦𝔱 𝔬𝔲𝔱.
parent?unset:)live word after it has been draw?live word"? live word of the screen"304x0"type word".diagram dialect and why I was so sad when I thought it wasn't developed anymore? )augmented help command will highlight the REPL code and draws arrows to or from it, pointing Diagrams to show additional help information, object structure and so on. To me REPL editing can remain as it was but the new Toomas experiments are showing us that higher interaction levels can be reached.parse, side running from the the current data/code flow, will be able to interpret it and return back to Red when needed. (Something that reminds me Arexx on Amiga)parse rules, so you can visually lint code, show questionable formatting or constructs. That can be done in a tool, or a company's standards committee.line (which I'm guessing) snaps to horz for example. This makes for clean annotations, and you don't need to switch contexts (screenshot, open paint, paste, draw, save, ...)%screenshot.png file can be dragged into Gitter, also copy made in some image editing program can be pasted.write-clipboard draw 100x50 [text 10x10 "Some text here"]
circle ellipse square rectangle box arrow
console add .notes ;take quick notes while playing (try `note 'last | note <int>` or enter issue(s) as marker(s) and then `note/to #start #end` ) finder ;find words and draw on screen, capture into %screenshot.png live <lit-word or lit-path> ;live editing experiment reminder ;experiments with reminder history ;quick selection from console's history (with contextual menu) into notes or caret (click) define ;adaptation of @rebolek's `where` helper ;console hot-keys only so far styles ;play with console's styling options
on-menu actor was more interesting. But with Red's reflective powers it is pure fun.[a a a]context-id should be shown in the heading of such pane or overing a word, in the REPL, so if the users see 2 different IDs, they will also acknowledge that contexts that display the same are different. (But I don't think it could be possible, as Red does not make the internal context ID available)show-context 'word|[words] could make visible the start of the context contents as tooltips.ctrl? I have to meditate on a more subtle way.mold ;)c/1?Notes is general note-taking tool. Needs some work still, but I added a Note button to Helper:[a a a] when all symbols have the same value and context have equal content or no other content. This because such a scenario happens not so often and we have enough context visibility to let newcomers automatically suspect the contexts can be different. probe single values (the print model of debugging), and set breakpoints or watchpoints on vars. An expression could show you not only the final result, but intermediate results that don't have vars defined for them. ... means you're not at the head of the block. There could even be decals/hints about how many items come before or after, so you can keep the hints short and ellipsize both ends.range. ;^)blk: [a b c 1 + 3]() show add first back find blk '+ first next find blk '+ blk: [a 2 b 3 c 4]() show power add first next find blk 'b last blk pick blk first next blk show power add blk/b blk/c blk/a
>> show add first back find blk '+ first next find blk '+
4 1 [1 + 3] [+ 3] 3 [3] [+ 3]
== 4
>> show power add first next find blk 'b last blk pick blk first next blk
49 7 3 [3 c 4] [b 3 c 4] 4 2 2 [2 b 3 c 4]
== 49
>> show power add blk/b blk/c blk/a
49 7
== 49trace-deep gives you the copied expression to be evaluated, which you can look for (deeply) in the original. Although it's not a 100% precise method. It copies because it modifies the original, while it evaluates. original/1/3/2/4...) to serve as a pointer.findpickpick is the following:add it is just keyword, not function).func then pausing. The hint system, after a few seconds, shows func spec [block!] body [block!] in a tooltip. Func is maybe a bad example, because ultimately and eventually, it's a prime candidate for a code template. My editor does this today, though it's mainly useful as you're learning, or for more complex calls. I need to fire up VSCode and play with the plugin there.find and a / gives you a list of refinements, where a space gives you a param name hint. The VSCode plugin isn't working here, so I can't test to see what it does. Templates are interesting to me, because they're in between no-help-at-all and block programming.[word "Tooltip text"] couples the develper can pass to your code.get-text word function. Your code will run this function with the hovered word as argument and receive get the text to display as result. on-hovered-word actor (@qtxie) which fires and a face/hovered-word that countains the word/value under the mouse pointer. This will let you have the full power of Red words under you fingers to display context relative text, or perform word relative action on any text data you are presenting in your GUI!Sell 100 shares of "Acme" at $47.97 per share (do you [remember](http://www.rebol.com/docs/core23/rebolcore-4.html#section-1) it?) and after you type at a listview of suggested prices opens! digit: charset "0123456789"
to-append: copy ""
total: 0
number: none
price: none
rule: [
any space
set action ["buy" | "sell"]
any space
not ahead
[set number
some digit]
(
prin ["number: " ] probe number
either none? number [
to-append: select-value quantities
prin ["To-append: " ] probe to-append: rejoin [" " to-append]
]
[
to-append: ""
]
)
if (to-append <> "") insert to-append
(probe "xxx" probe to-append: "" probe number: none) ;<----- it is never executed
]
shares: ["22.00" "35.22" "44.35"]
quantities: ["1" "2" "3" "4" "5" "6" "7" "8" "9"]
select-value: func [data-block /local out-data] [
view [
below
text-list 100x80 data data-block on-change [
out-data: data-block/(face/selected)
]
]
out-data
]
View [
text "example: Sell 10 shares at 20"
field 350x40 on-key [
current-text: none
if all [not none? face/text not empty? face/text] [parse probe face/text rule]
]
]on-key-up.either body? What about with the stuff like case? Will you change the color for each condition part?case has one argument - therefore one color, either has three arguments (condition and two blocks), therefore three colors. Set-words have an expression for "argument" - one color.values access private contexts?Red [] #include %q-v.red v: q-v/duplicate view/flags v/window 'resize
Red [] #include %q-v.red v: q-v/duplicate/widths [50 50 30 80] v/window/size: 400x200 view/flags v/window 'resize
q-v ["Quick View Demo" 600x400 [50 50 30 80] order [l r t b] resize colors [c white]]
Courier New works on all three platforms, even though i found that on W10 text without background colour is not transparent.[200x50 150x25] would be [200 50 150 25] in [l t b r] or some other order. [1 2 3 4]) become named as well./order and /widths params eg. [top 50 right 70 bottom 30 left 100]sizes: [top 50 right 70 bottom 30 left 100] format, then access as sizes/top sizes/left etc.top: any [sizes/top 50] then use top in the rest of the code.sizing: function [sizes [block!]][ defs: [top 50 left 200 right 150 bottom 25] sizes: append copy sizes defs ; this is the tricky bit probe reduce [sizes/top sizes/left sizes/right sizes/bottom] ] sizing [top 500 left 2000 right 1500 bottom 250] sizing [top 100 bottom 75] sizing [left 300 right 90] sizing []
dims, sizes, and face facets are used in coordination.duplicate as a method, internally copying the context and using v as the ref to it throughout, consider a make model. e.g. view-a: make-quick-view . It's more idiomatically Red, and avoids having an object's method copying its parent context from the inside which is a little mind bending. This being the sandbox, I imagine people will come up with *really* clever ideas for how to leverage and abuse that approach. ;^)make-quick-view wouldn't be inside the context, but make use of it. It may not work, as your code might rely on bindings in such a way that it breaks things.transcode feature here.bivector. =8^@>> cayley/show/with [0 1 0] 1 e1 e1 -1
>> cayley/show/with [2 0 0] 1 e1 e2 e12 e1 1 -e12 -e2 e2 e12 1 e1 e12 e2 -e1 -1
>> cayley/show/with [3 0 1] 1 e0 e1 e2 e3 e01 e02 e03 e12 e13 e23 e012 e013 e023 e123 e0123 e0 0 -e01 -e02 -e03 0 0 0 e012 e013 e023 0 0 0 -e0123 0 e1 e01 1 -e12 -e13 e0 -e012 -e013 -e2 -e3 e123 -e02 -e03 e0123 e23 e023 e2 e02 e12 1 -e23 e012 e0 -e023 e1 -e123 -e3 e01 -e0123 -e03 -e13 -e013 e3 e03 e13 e23 1 e013 e023 e0 e123 e1 e2 e0123 e01 e02 e12 e012 e01 0 -e0 e012 e013 0 0 0 -e02 -e03 e0123 0 0 0 -e023 0 e02 0 -e012 -e0 e023 0 0 0 e01 -e0123 -e03 0 0 0 e013 0 e03 0 -e013 -e023 -e0 0 0 0 e0123 e01 e02 0 0 0 -e012 0 e12 e012 e2 -e1 e123 e02 -e01 e0123 -1 e23 -e13 -e0 e023 -e013 -e3 -e03 e13 e013 e3 -e123 -e1 e03 -e0123 -e01 -e23 -1 e12 -e023 -e0 e012 e2 e02 e23 e023 e123 e3 -e2 e0123 e03 -e02 e13 -e12 -1 e013 -e012 -e0 -e1 -e01 e012 0 -e02 e01 -e0123 0 0 0 -e0 e023 -e013 0 0 0 e03 0 e013 0 -e03 e0123 e01 0 0 0 -e023 -e0 e012 0 0 0 -e02 0 e023 0 -e0123 -e03 e02 0 0 0 e013 -e012 -e0 0 0 0 e01 0 e123 e0123 e23 -e13 e12 e023 -e013 e012 -e3 e2 -e1 -e03 e02 -e01 -1 -e0 e0123 0 -e023 e013 -e012 0 0 0 -e03 e02 -e01 0 0 0 e0 0
*** Math Error: math or number overflow *** Where: multiply *** Stack: play view do-events do-actor do-safe on-click render
nearby at the start doesn't display anything either, yeah. nearby should be defined not in this window, but in file %d201.red.mee: [ system/script/args: to-file system/script/args write system/script/args "" x: words-of system/words forall x [ if value? first x [ if find [function! native! action! op! routine!] ty: to-word type? get first x [WRITE/append/lines system/script/args TO-STRING first x] ; [prin [first x " : " spec-of get first x] probe ty] ] ] ] do/args mee "words-red.txt" save %save-words.r head insert tail insert copy mee reduce ['Red []] reduce ['quit] ;---------------vvvvvvvvvvv---Change-here----------------- call/show/wait "red-063.exe save-words.r words-red-old.txt" foreach word sort exclude read/lines %words-red.txt read/lines %words-red-old.txt [ Print ["New-word: " word] ] delete %words-red-old.txt delete %words-red.txt delete %save-words.txt
New-word: alert New-word: as-money New-word: average New-word: caret-to-offset New-word: close New-word: compress New-word: count-chars New-word: create New-word: debug-info? New-word: decode-url New-word: decompress New-word: deep-reactor New-word: dt New-word: encode-url New-word: last? New-word: load-csv New-word: load-json New-word: make-face New-word: money? New-word: offset-to-caret New-word: offset-to-char New-word: open New-word: open? New-word: os-info New-word: query New-word: reactor New-word: recycle New-word: ref? New-word: register-scheme New-word: rename New-word: rtd-layout New-word: scan New-word: set-slot-quiet New-word: single? New-word: stop-events New-word: stop-reactor New-word: sum New-word: to-csv New-word: to-json New-word: to-local-date New-word: to-money New-word: to-ref New-word: to-UTC-date New-word: transcode New-word: update New-word: _save-cfg
Rebol.exe in the current script dir and change the following lines:save %save-words.r head insert tail insert copy mee reduce ['Red []] reduce ['quit] ;---------------vvvvvvvvvvv---Change-here----------------- call/show/wait "red-063.exe save-words.r words-red-old.txt"
save %save-words.r head insert tail insert copy mee reduce ['Rebol []] reduce ['quit] call/show/wait "rebol.exe save-words.r words-rebol.txt"
New-word: % New-word: << New-word: >> New-word: >>> New-word: a-an New-word: acos New-word: alert New-word: all-word? New-word: any-list? New-word: arctangent2 New-word: as New-word: as-color New-word: as-ipv4 New-word: as-money New-word: as-rgba New-word: asin New-word: atan New-word: atan2 New-word: average New-word: caret-to-offset New-word: center-face New-word: class-of New-word: clear-reactions New-word: complement? New-word: context? New-word: continue New-word: cos New-word: count-chars New-word: create New-word: create-dir New-word: debug-info? New-word: deep-reactor New-word: dir New-word: distance? New-word: do-actor New-word: do-events New-word: do-file New-word: do-safe New-word: do-thru New-word: draw New-word: dump-face New-word: dump-reactions New-word: ellipsize-at New-word: encode-url New-word: eval-set-path New-word: exists-thru? New-word: expand New-word: expand-directives New-word: extend New-word: extract-boot-args New-word: face? New-word: fetch-help New-word: find-flag? New-word: flip-exe-flag New-word: float? New-word: foreach-face New-word: get-current-dir New-word: get-scroller New-word: handle? New-word: help-string New-word: hex-to-rgb New-word: immediate? New-word: insert-event-func New-word: is New-word: keys-of New-word: last-lf? New-word: layout New-word: link-sub-to-parent New-word: link-tabs-to-parent New-word: ll New-word: load-csv New-word: load-json New-word: load-thru New-word: make-face New-word: math New-word: metrics? New-word: modify New-word: NaN? New-word: normalize-dir New-word: object New-word: offset-to-caret New-word: offset-to-char New-word: on-face-deep-change* New-word: open? New-word: os-info New-word: overlap? New-word: pad New-word: parse-trace New-word: path-thru New-word: percent? New-word: put New-word: quit-return New-word: react New-word: react? New-word: reactor New-word: read-clipboard New-word: read-thru New-word: red-complete-input New-word: ref? New-word: register-scheme New-word: remove-event-func New-word: request-dir New-word: request-file New-word: request-font New-word: routine New-word: rtd-layout New-word: scan New-word: set-current-dir New-word: set-flag New-word: set-focus New-word: set-quiet New-word: set-slot-quiet New-word: shift-left New-word: shift-logical New-word: shift-right New-word: show New-word: sin New-word: single? New-word: size-text New-word: split New-word: sqrt New-word: stop-events New-word: stop-reactor New-word: sum New-word: tan New-word: to-csv New-word: to-float New-word: to-json New-word: to-local-date New-word: to-percent New-word: to-red-file New-word: to-ref New-word: to-unset New-word: to-UTC-date New-word: transcode New-word: unview New-word: update-font-faces New-word: vector? New-word: view New-word: within? New-word: write-clipboard New-word: write-stdout New-word: _save-cfg
_save-cfg is a likely suspect.red-complete-input is likely from the console, etc.mark-my-words which helped me track leaked words.set-slot-quiet makes me curios.on-face-deep-change* also seems a leaked wordREBOL []
mark-my-words: context [
init: does [query/clear system/words]
dump: has [val] [
print ['Word tab 'Type tab 'Value]
foreach word query system/words [
print [word tab type? val: get word tab either not object? :val [mold :val] [mold first :val]]
]
]
set 'globals? func [file [file!]] [
query/clear system/words
do file
mark-my-words/dump
print ['Word tab 'Type tab 'Value]
foreach word query system/words [
print [word tab type? val: get word tab either not object? :val [mold :val] [mold first :val]]
]
]
]
; Usage:
; mark-my-words/init
;
; o: make object! [a: b: c: none set 'xx none]
; my-int: 23
; I-have-issues: #this-is-my-biggest-issue
; fn: does [print "some fun now!"]
;
; mark-my-words/dump
; halt
globals? %stopwatch.r
haltNew-word: as-money New-word: count-chars New-word: dt New-word: enhex New-word: money? New-word: ref? New-word: scan New-word: set-slot-quiet New-word: to-money New-word: to-ref New-word: transcode New-word: transcode-trace
DT which benchmarks a block execution.algebra.red and rubik222.red too.)x, y or z and then wheel to rotate whole cube.money!.money! values, can they?colors: exclude sort extract load help-string tuple! 2 [transparent glass]
view/tight collect [
until [
foreach color take/part colors 4 [
keep reduce [
'base 70x40 form color get color pick [white black] gray > get color
]
]
keep 'return
empty? colors
]
]gray > get color test? Whereas the Red color passes the test. All three have one at least one color maxed-out at 255, with cyan having green and blue, but both green and cyan not having red, but being of a very high intensity color wise.FALSE renders BLACK text andTRUE renders WHITE textforeach c [red green cyan blue][col-tup: (reduce c) print compose[c (col-tup) (gray > col-tup)]]
red 255.0.0 false ;white green 0.255.0 true ;black cyan 0.255.255 true ;black blue 0.0.255 true ;black
foreach c [yellow brick brown sky][col-tup: (reduce c) print compose[c (col-tup) (gray > col-tup)]]
yellow 255.255.0 false ;white brick 178.34.34 false ;white brown 139.69.19 false ;white sky 164.200.255 false ;white 0.200.255 0.200.255 true ;black 1.255.255 1.255.255 true ;black
foreach c [0.255.255 64.255.255 128.255.255][col-tup: (reduce c) print compose[c (col-tup) (gray > col-tup)]]
0.255.255 0.255.255 true ;black 64.255.255 64.255.255 true ;black 128.255.255 128.255.255 false ;white
>> sort reduce [yellow brick brown sky gray] == [128.128.128 139.69.19 164.200.255 178.34.34 255.255.0]
bright?: func [color [tuple!]][
50% < divide third sort to binary! color 255
]
colors: exclude sort extract load help-string tuple! 2 [transparent glass]
view/tight collect [
until [
foreach color take/part colors 4 [
keep reduce [
'base 70x40 lowercase form color get color pick [black white] bright? get color
]
]
keep 'return
empty? colors
]
]img1: draw 120x120 [ anti-alias off pen off box 0x0 119x119 pen black line-width 10 fill-pen red circle 59x59 40 ]
view [backdrop blue image img1]
img/argb should be fasterargb too. But you have still to "smudge" the color as they are sometimes set off a bit.img/alpha/: <1 - 255> This seems to have no effect. Neither does it work on rgb nor on argb. Only changing the whole lot at once works, i.e. img/alpha: 255. Same for rgb and argb. But for these it is rarely needed I guess. Is it intended or bug?argb then set it back img/argb: .. and it'll be faster than mold/loadkey-color ? http://www.rebol.com/docs/draw.html#section-14image!, not from inside Draw dialect? Or it will remain a task for user func?transparent, and interestingly, while manipulating argb as you suggested is more memory-efficient, it will slow down in proportion to length of changed color, but time of my original method will remain ~constant.set 'transparent function [img [image!] color [tuple!]][
spec: load mold img
color: smudge color
alpha: rejoin parse spec/3/2 [
collect some [
color keep (#{FF})
| 3 skip keep (#{00})
]
]
append spec/3 alpha
do spec
]
set 'transparent2 function [img [image!] color [tuple!]][
img: copy img
color: reverse smudge color
argb: copy img/argb
parse argb [
some [
color change skip (#{00})
| 4 skip
]
]
img/argb: argb
img
]>> profile/count/show [[transparent img1 black][transparent2 img1 black]] 100 Count: 100 Time | Time (Per) | Memory | Code 0:00:01.85 | 0:00:00.019 | 17341884 | [transparent2 img1 black] 0:00:01.886 | 0:00:00.019 | 176054040 | [transparent img1 black] >> profile/count/show [[transparent img1 red][transparent2 img1 red]] 100 Count: 100 Time | Time (Per) | Memory | Code 0:00:01.827 | 0:00:00.018 | 176055640 | [transparent img1 red] 0:00:02.242 | 0:00:00.022 | 17343484 | [transparent2 img1 red] >> profile/count/show [[transparent img1 white][transparent2 img1 white]] 100 Count: 100 Time | Time (Per) | Memory | Code 0:00:01.76 | 0:00:00.018 | 176058840 | [transparent img1 white] 0:00:03.535 | 0:00:00.035 | 17346684 | [transparent2 img1 white]
set 'transparent3 function [img [image!] color [tuple!]][
img: copy img
color: smudge reverse color
argb: img/argb
img/alpha: to #{} parse/case argb [
collect [
some [
color keep #{00}
| 3 skip keep skip
]
]
]
img
]collect into but it's broken on binary :(change is that slowset 'transparent3 function [img [image!] color [tuple!]][
img: copy img
color: smudge reverse color
argb: img/argb
img/alpha: to #{} parse/case argb [
collect [
some [
color skip keep (#{FF})
| 4 skip keep (#{00})
]
]
]
img
]set 'transparent4 function [img [image!] color [tuple!]][ img: copy img repeat i length? img [ all [ 1 >= absolute (a: img/:i/1) - color/1 1 >= absolute (b: img/:i/2) - color/2 1 >= absolute (c: img/:i/3) - color/3 img/:i: as-rgba a b c 255 ] ] img ]
image!, not from inside Draw dialect? Or it will remain a task for user func?transparent is any func from above. For some reason switching off anti-aliasing seems sometimes not to work and there are still half-tones. I added a step to eliminate these but this makes font fatter. The version above was made without this step.xmas: make font! [size: 32 style: 'bold]
ximg: draw 360x70 [
anti-alias off
fill-pen white pen off
box 0x0 359x69
pen black font xmas
text 4x0 "Merry Christmas!"
]
ximg/rgb: to #{} parse ximg/rgb [
collect some [keep #{FFFFFF} | 3 skip keep (#{010101})]
]
do %transparent.red
xi: transparent ximg black
img: load %rainbow.png
view/tight/flags [
title ""
box 360x70
draw [
i1: image img 0x0 359x69
i2: image img -360x0 -1x69
] on-time [
x1: i1/3/x + 5 % 360
i1/3/x: i2/4/x: x1
i1/4/x: x1 + 360
i2/3/x: x1 - 360
]
rate 30
at 0x0 image xi
][no-min no-max]rainbow.png:moldnum-palindrome?: func [num [integer!]][either negative? num [false][num == load reverse mold num]]
palindrome: func [input][(a: form input) = reverse copy a]
+909?: func [n [integer!]][ if find n: append copy http:// n '- [false] (last split n "//") == (first split reverse n "//") ]
pal-int-rome: function [i [integer!]][
case [
i = 0 [return true]
i < 0 [return false]
'else [
n: 1
pieces: clear []
while [i > 0][
append pieces i - (i: round/floor/to i m: 10 ** n) / (m / 10)
n: n + 1
]
pieces = reverse copy pieces
]
]
]
pal-int-rome 11 ;== true
pal-int-rome 12 ;== false
pal-int-rome 22 ;== true
pal-int-rome 222 ;== true
pal-int-rome 322 ;== false
pal-int-rome 22322 ;== true
pal-int-rome 22332 ;== false
pal-int-rome 23332 ;== true
pal-int-rome -23332 ;== false
;But also...
pal-int-rome +23332 ;== true
pal-int-rome -0 ;== truexfont: make font! [size: 32 style: 'bold]
sz: 360x70
ximg: draw sz [font xfont text 4x0 "Merry Christmas!"]
area: make-face 'area [size: 1200x20]
make-merry: func [/color clr [tuple!] /font fspec [block!] /text txt /pad pd][
if font [xfont: make font! fspec]
pd: any [pd 4x0]
if text [
area/font: xfont
sz: size-text/with area txt
ximg: draw sz compose [font xfont text (pd) (txt)]
]
clr: either color [reverse to-binary clr][#{FFFFFF}]
xi: copy ximg
xi/argb: to #{} parse xi/argb [
collect some [set a 3 skip keep (clr) skip keep (a)]
]
system/view/auto-sync?: off
view/tight/flags compose/deep [
title ""
box (sz) draw [
pen off
fill-pen linear blue green yellow red blue
i1: box 0x0 (sz - 1)
i2: box (as-pair 0 - sz/x 0) (as-pair 0 sz/y - 1)
] on-time [
x1: i1/2/x + 5 % (sz/x)
i1/2/x: i2/3/x: x1
i1/3/x: x1 + (sz/x)
i2/2/x: x1 - (sz/x)
show face
] rate 30
at 0x0 image xi
][no-min no-max]
]make-merry make-merry/text "Happy New Year!" make-merry/color/font sky [size: 48 style: 'bold name: "Courier New"]