-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
2 lines (2 loc) · 764 KB
/
index.html
1
2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional"><!-- saved from url=(0040)./index.html --><html><style id="Force_Custom_Fonts" type="text/css">@font-face{font-style:normal;font-family:"Noto Sans CJK SC Regular";src:local("Noto Sans CJK SC Regular")}@font-face{font-style:bolder;font-family:"Noto Sans CJK SC Regular";src:local("Noto Sans CJK SC Regular")}:not(pre):not(code):not(textarea):not(tt):not(kbd):not(samp):not(var){font-family:"Noto Sans CJK SC Regular"!important}pre,code,textarea,tt,kbd,samp,var{font-family:"Noto Sans Mono CJK SC Regular"!important}pre *,code *,textarea *,tt *,kbd *,samp *,var *{font-family:"Noto Sans Mono CJK SC Regular"!important}</style><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Red 语言实例</title><style type="text/css">html, body, p, td, li {font-family: arial, sans-serif, helvetica; font-size: 10pt;}h1 {font-size: 16pt; Font-Weight: bold;}h2 {font-size: 14pt; color: #2030a0; Font-Weight: bold; width: 100%; border-bottom: 1px solid #c09060;}h3 {font-size: 12pt; color: #2030a0; Font-Weight: bold;}h4 {font-size: 10pt; color: #2030a0; Font-Weight: bold;}h5 {font-size: 10pt; Font-Weight: bold;}tt {font-family: "courier new", monospace, courier; color: darkgreen;}pre {font: bold 10pt "courier new", monospace, console; background-color: #f4f6f6; padding: 16px; border: solid #a0a0a0 1px;}.toc1 {margin-left: 1cm; font-size: 12pt; font-weight: bold;}.toc2 {margin-left: 2cm; font-size: 10pt; font-weight: bold; text-decoration: none;}.toc3 {margin-left: 3cm; font-size: 10pt; text-decoration: none;}.toc4 {margin-left: 4cm; font-size: 10pt; color: grey; text-decoration: none;}.output {color: #000080; font-weight: normal;}.note {background-color: #f0e090; width: 100%; padding: 16px; border: solid #a0a0a0 1px;}.tail {color: gray; font-size: 8pt;}.mike-large{color:blue; font-size: 13pt; font-weight:bold; } .mike-small{ font-size: 10pt; }</style><style>#BAIDU_DSPUI_FLOWBAR,.adsbygoogle,.ad,div[class^="ad-widsget"],div[id^="div-gpt-ad-"],a[href*="@"][href*=".exe"],a[href*="/?/"][href*=".exe"],.adpushwin{display:none!important;max-width:0!important;max-height:0!important;overflow:hidden!important;}</style><script type="text/javascript" src="chrome-extension://ggfnopabjhlbcmchfajkadagogmohglj/js/page.js"></script><script charset="utf-8" src="chrome-extension://jgphnjokjhjlcnnajmfjlacjnjkhleah/js/btype.js"></script></head><body bgcolor="white"><center><table width="660" cellpadding="4" cellspacing="0" border="0"><tbody><tr><td><!----------------------------------------------------------------------------><h1 style="color:red; id=top">Red 语言实例 - 一个可访问的实例参考</h1>最后更新于 2017 年 5 月 24 日<h2>index</h2><pre><a href="./index.html">index</a> <a href="./parse.html">parse</a> <a href="./vid.html">vid</a> <a href="./series.html">series</a> <a href="./help.html">help</a> <a href="./about.html">about</a> <a href="./links.html">links</a> <a href="./contact.html">contact</a> </pre><h2 id="ix-alpha">GUI(VID)方言关键字以字母数字顺序排列</h2><pre><a href="./index.html#0across">across</a> <a href="./index.html#0all-over">all-over</a> <a href="./index.html#0aqua">aqua</a> <a href="./index.html#0area">area</a> <br><a href="./index.html#0at">at</a> <a href="./index.html#0beige">beige</a> <a href="./index.html#0below">below</a> <a href="./index.html#0black">black</a> <br><a href="./index.html#0blue">blue</a> <a href="./index.html#0bold">bold</a> <a href="./index.html#0bottom">bottom</a> <a href="./index.html#0brick">brick</a> <br><a href="./index.html#0brown">brown</a> <a href="./index.html#0button">button</a> <a href="./index.html#0center">center</a> <a href="./index.html#0center-face">center-face</a> <br><a href="./index.html#0check">check</a> <a href="./index.html#0check-all-reactions">check-all-reactions</a> <a href="./index.html#0check-reactions">check-reactions</a> <a href="./index.html#0coal">coal</a> <br><a href="./index.html#0coffee">coffee</a> <a href="./index.html#0crimson">crimson</a> <a href="./index.html#0cyan">cyan</a> <a href="./index.html#0data">data</a> <br><a href="./index.html#0default">default</a> <a href="./index.html#0disabled">disabled</a> <a href="./index.html#0do">do</a> <a href="./index.html#0draw">draw</a> <br><a href="./index.html#0drop-down">drop-down</a> <a href="./index.html#0drop-list">drop-list</a> <a href="./index.html#0dump-face">dump-face</a> <a href="./index.html#0eventxqm">event?</a> <br><a href="./index.html#0extra">extra</a> <a href="./index.html#0facet">facet</a> <a href="./index.html#0field">field</a> <a href="./index.html#0find-flagxqm">find-flag?</a> <br><a href="./index.html#0focus">focus</a> <a href="./index.html#0font">font</a> <a href="./index.html#0font-color">font-color</a> <a href="./index.html#0font-name">font-name</a> <br><a href="./index.html#0font-size">font-size</a> <a href="./index.html#0forest">forest</a> <a href="./index.html#0gold">gold</a> <a href="./index.html#0gray">gray</a> <br><a href="./index.html#0green">green</a> <a href="./index.html#0hidden">hidden</a> <a href="./index.html#0insert-event-func">insert-event-func</a> <a href="./index.html#0italic">italic</a> <br><a href="./index.html#0ivory">ivory</a> <a href="./index.html#0khaki">khaki</a> <a href="./index.html#0leaf">leaf</a> <a href="./index.html#0left">left</a> <br><a href="./index.html#0linen">linen</a> <a href="./index.html#0link-sub-to-parent">link-sub-to-parent</a> <a href="./index.html#0link-tabs-to-parent">link-tabs-to-parent</a> <a href="./index.html#0loose">loose</a> <br><a href="./index.html#0magenta">magenta</a> <a href="./index.html#0maroon">maroon</a> <a href="./index.html#0middle">middle</a> <a href="./index.html#0mint">mint</a> <br><a href="./index.html#0navy">navy</a> <a href="./index.html#0needs">needs</a> <a href="./index.html#0no-wrap">no-wrap</a> <a href="./index.html#0offsetxqm">offset?</a> <br><a href="./index.html#0oldrab">oldrab</a> <a href="./index.html#0olive">olive</a> <a href="./index.html#0on-alt-down">on-alt-down</a> <a href="./index.html#0on-alt-up">on-alt-up</a> <br><a href="./index.html#0on-aux-down">on-aux-down</a> <a href="./index.html#0on-aux-up">on-aux-up</a> <a href="./index.html#0on-change">on-change</a> <a href="./index.html#0on-click">on-click</a> <br><a href="./index.html#0on-close">on-close</a> <a href="./index.html#0on-create">on-create</a> <a href="./index.html#0on-dbl-click">on-dbl-click</a> <a href="./index.html#0on-detect">on-detect</a> <br><a href="./index.html#0on-down">on-down</a> <a href="./index.html#0on-drag">on-drag</a> <a href="./index.html#0on-drag-start">on-drag-start</a> <a href="./index.html#0on-drop">on-drop</a> <br><a href="./index.html#0on-enter">on-enter</a> <a href="./index.html#0on-face-deep-changexmu">on-face-deep-change*</a> <a href="./index.html#0on-focus">on-focus</a> <a href="./index.html#0on-key">on-key</a> <br><a href="./index.html#0on-key-down">on-key-down</a> <a href="./index.html#0on-key-up">on-key-up</a> <a href="./index.html#0on-menu">on-menu</a> <a href="./index.html#0on-mid-down">on-mid-down</a> <br><a href="./index.html#0on-mid-up">on-mid-up</a> <a href="./index.html#0on-move">on-move</a> <a href="./index.html#0on-moving">on-moving</a> <a href="./index.html#0on-over">on-over</a> <br><a href="./index.html#0on-pan">on-pan</a> <a href="./index.html#0on-parse-event">on-parse-event</a> <a href="./index.html#0on-press-tap">on-press-tap</a> <a href="./index.html#0on-resize">on-resize</a> <br><a href="./index.html#0on-resizing">on-resizing</a> <a href="./index.html#0on-rotate">on-rotate</a> <a href="./index.html#0on-select">on-select</a> <a href="./index.html#0on-time">on-time</a> <br><a href="./index.html#0on-two-tap">on-two-tap</a> <a href="./index.html#0on-unfocus">on-unfocus</a> <a href="./index.html#0on-up">on-up</a> <a href="./index.html#0on-zoom">on-zoom</a> <br><a href="./index.html#0orange">orange</a> <a href="./index.html#0origin">origin</a> <a href="./index.html#0overlapxqm">overlap?</a> <a href="./index.html#0pad">pad</a> <br><a href="./index.html#0papaya">papaya</a> <a href="./index.html#0para">para</a> <a href="./index.html#0pewter">pewter</a> <a href="./index.html#0pink">pink</a> <br><a href="./index.html#0purple">purple</a> <a href="./index.html#0radio">radio</a> <a href="./index.html#0rate">rate</a> <a href="./index.html#0react">react</a> <br><a href="./index.html#0reblue">reblue</a> <a href="./index.html#0rebolor">rebolor</a> <a href="./index.html#0red">red</a> <a href="./index.html#0remove-event-func">remove-event-func</a> <br><a href="./index.html#0remove-reactor">remove-reactor</a> <a href="./index.html#0return">return</a> <a href="./index.html#0right">right</a> <a href="./index.html#0select">select</a> <br><a href="./index.html#0set-flag">set-flag</a> <a href="./index.html#0show">show</a> <a href="./index.html#0size-text">size-text</a> <a href="./index.html#0slider">slider</a> <br><a href="./index.html#0style">style</a> <a href="./index.html#0tab-panel">tab-panel</a> <a href="./index.html#0text">text</a> <a href="./index.html#0text-list">text-list</a> <br><a href="./index.html#0top">顶部</a> <a href="./index.html#0underline">underline</a> <a href="./index.html#0update-font-faces">update-font-faces</a> <a href="./index.html#0wrap">wrap</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="ix-alpha">用字母数字顺序解析方言关键字</h2><pre><a href="./index.html#1copy">copy</a> <a href="./index.html#1skip">skip</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="ix-alpha">Red 语言关键字以字母数字顺序排列</h2><pre><a href="./index.html#xpc">%</a> <a href="./index.html#xmu">*</a> <a href="./index.html#xmuxmu">**</a> <a href="./index.html#xpl">+</a> <br><a href="./index.html#-">-</a> <a href="./index.html#xsl">/</a> <a href="./index.html#xslxsl">//</a> <a href="./index.html#xlt"><</a> <br><a href="./index.html#xltxlt"><<</a> <a href="./index.html#xltxeq"><=</a> <a href="./index.html#xltxgt"><></a> <a href="./index.html#xeq">=</a> <br><a href="./index.html#xeqxeq">==</a> <a href="./index.html#xeqxqm">=?</a> <a href="./index.html#xgt">></a> <a href="./index.html#xgtxeq">>=</a> <br><a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> <a href="./index.html#xqm"></a> <a href="./index.html#xqmxqm">?</a> <br><a href="./index.html#a-an">a-an</a> <a href="./index.html#about">about</a> <a href="./index.html#absolute">absolute</a> <a href="./index.html#acos">acos</a> <br><a href="./index.html#actionxex">action!</a> <a href="./index.html#actionxqm">action?</a> <a href="./index.html#add">add</a> <a href="./index.html#all">all</a> <br><a href="./index.html#also">also</a> <a href="./index.html#alter">alter</a> <a href="./index.html#and">and</a> <a href="./index.html#andxsn">and~</a> <br><a href="./index.html#any">any</a> <a href="./index.html#any-blockxqm">any-block?</a> <a href="./index.html#any-functionxqm">any-function?</a> <a href="./index.html#any-listxex">any-list!</a> <br><a href="./index.html#any-listxqm">any-list?</a> <a href="./index.html#any-objectxex">any-object!</a> <a href="./index.html#any-objectxqm">any-object?</a> <a href="./index.html#any-pathxex">any-path!</a> <br><a href="./index.html#any-pathxqm">any-path?</a> <a href="./index.html#any-stringxex">any-string!</a> <a href="./index.html#any-stringxqm">any-string?</a> <a href="./index.html#any-word">any-word</a> <br><a href="./index.html#any-wordxqm">any-word?</a> <a href="./index.html#append">append</a> <a href="./index.html#arccosine">arccosine</a> <a href="./index.html#arcsine">arcsine</a> <br><a href="./index.html#arctangent">arctangent</a> <a href="./index.html#arctangent2">arctangent2</a> <a href="./index.html#as-color">as-color</a> <a href="./index.html#as-ipv4">as-ipv4</a> <br><a href="./index.html#as-pair">as-pair</a> <a href="./index.html#as-rgba">as-rgba</a> <a href="./index.html#asin">asin</a> <a href="./index.html#ask">ask</a> <br><a href="./index.html#at">at</a> <a href="./index.html#atan">atan</a> <a href="./index.html#atan2">atan2</a> <a href="./index.html#attempt">attempt</a> <br><a href="./index.html#back">back</a> <a href="./index.html#binaryxex">binary!</a> <a href="./index.html#binaryxqm">binary?</a> <a href="./index.html#bind">bind</a> <br><a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#bitsetxqm">bitset?</a> <a href="./index.html#blockxex">block!</a> <a href="./index.html#blockxqm">block?</a> <br><a href="./index.html#body-of">body-of</a> <a href="./index.html#break">break</a> <a href="./index.html#browse">browse</a> <a href="./index.html#call">call</a> <br><a href="./index.html#case">case</a> <a href="./index.html#catch">catch</a> <a href="./index.html#cause-error">cause-error</a> <a href="./index.html#cd">cd</a> <br><a href="./index.html#change">change</a> <a href="./index.html#change-dir">change-dir</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#charxqm">char?</a> <br><a href="./index.html#charset">charset</a> <a href="./index.html#checksum">checksum</a> <a href="./index.html#clean-path">clean-path</a> <a href="./index.html#clear">clear</a> <br><a href="./index.html#clear-reactions">clear-reactions</a> <a href="./index.html#collect">collect</a> <a href="./index.html#comment">comment</a> <a href="./index.html#complement">complement</a> <br><a href="./index.html#complementxqm">complement?</a> <a href="./index.html#compose">compose</a> <a href="./index.html#construct">construct</a> <a href="./index.html#context">context</a> <br><a href="./index.html#contextxqm">context?</a> <a href="./index.html#continue">continue</a> <a href="./index.html#copy">copy</a> <a href="./index.html#cos">cos</a> <br><a href="./index.html#cosine">cosine</a> <a href="./index.html#create-dir">create-dir</a> <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#datatypexqm">datatype?</a> <br><a href="./index.html#debase">debase</a> <a href="./index.html#default-input-completer">default-input-completer</a> <a href="./index.html#dehex">dehex</a> <a href="./index.html#difference">difference</a> <br><a href="./index.html#dir">dir</a> <a href="./index.html#dirxqm">dir?</a> <a href="./index.html#dirize">dirize</a> <a href="./index.html#divide">divide</a> <br><a href="./index.html#do">do</a> <a href="./index.html#do-actor">do-actor</a> <a href="./index.html#do-events">do-events</a> <a href="./index.html#do-file">do-file</a> <br><a href="./index.html#do-safe">do-safe</a> <a href="./index.html#does">does</a> <a href="./index.html#dump-reactions">dump-reactions</a> <a href="./index.html#either">either</a> <br><a href="./index.html#emailxex">email!</a> <a href="./index.html#emailxqm">email?</a> <a href="./index.html#emptyxqm">empty?</a> <a href="./index.html#enbase">enbase</a> <br><a href="./index.html#equalxqm">equal?</a> <a href="./index.html#errorxex">error!</a> <a href="./index.html#errorxqm">error?</a> <a href="./index.html#eval-set-path">eval-set-path</a> <br><a href="./index.html#evenxqm">even?</a> <a href="./index.html#eventxex">event!</a> <a href="./index.html#exclude">exclude</a> <a href="./index.html#existsxqm">exists?</a> <br><a href="./index.html#exit">exit</a> <a href="./index.html#exp">exp</a> <a href="./index.html#extend">extend</a> <a href="./index.html#extract">extract</a> <br><a href="./index.html#extract-boot-args">extract-boot-args</a> <a href="./index.html#false">false</a> <a href="./index.html#fifth">fifth</a> <a href="./index.html#filexex">file!</a> <br><a href="./index.html#filexqm">file?</a> <a href="./index.html#find">find</a> <a href="./index.html#first">first</a> <a href="./index.html#flip-exe-flag">flip-exe-flag</a> <br><a href="./index.html#floatxex">float!</a> <a href="./index.html#floatxqm">float?</a> <a href="./index.html#forall">forall</a> <a href="./index.html#foreach">foreach</a> <br><a href="./index.html#forever">forever</a> <a href="./index.html#form">form</a> <a href="./index.html#fourth">fourth</a> <a href="./index.html#func">func</a> <br><a href="./index.html#function">function</a> <a href="./index.html#functionxex">function!</a> <a href="./index.html#functionxqm">function?</a> <a href="./index.html#get">get</a> <br><a href="./index.html#get-current-dir">get-current-dir</a> <a href="./index.html#get-env">get-env</a> <a href="./index.html#get-pathxex">get-path!</a> <a href="./index.html#get-pathxqm">get-path?</a> <br><a href="./index.html#get-wordxex">get-word!</a> <a href="./index.html#get-wordxqm">get-word?</a> <a href="./index.html#greater-or-equalxqm">greater-or-equal?</a> <a href="./index.html#greaterxqm">greater?</a> <br><a href="./index.html#halt">halt</a> <a href="./index.html#has">has</a> <a href="./index.html#hashxex">hash!</a> <a href="./index.html#hashxqm">hash?</a> <br><a href="./index.html#head">head</a> <a href="./index.html#headxqm">head?</a> <a href="./index.html#help">help</a> <a href="./index.html#if">if</a> <br><a href="./index.html#imagexex">image!</a> <a href="./index.html#imagexqm">image?</a> <a href="./index.html#in">in</a> <a href="./index.html#indexxqm">index?</a> <br><a href="./index.html#input">input</a> <a href="./index.html#insert">insert</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#integerxqm">integer?</a> <br><a href="./index.html#intersect">intersect</a> <a href="./index.html#is">is</a> <a href="./index.html#issuexex">issue!</a> <a href="./index.html#issuexqm">issue?</a> <br><a href="./index.html#keys-of">keys-of</a> <a href="./index.html#last">last</a> <a href="./index.html#last-lfxqm">last-lf?</a> <a href="./index.html#layout">layout</a> <br><a href="./index.html#lengthxqm">length?</a> <a href="./index.html#lesser-or-equalxqm">lesser-or-equal?</a> <a href="./index.html#lesserxqm">lesser?</a> <a href="./index.html#list-dir">list-dir</a> <br><a href="./index.html#list-env">list-env</a> <a href="./index.html#lit-pathxex">lit-path!</a> <a href="./index.html#lit-pathxqm">lit-path?</a> <a href="./index.html#lit-wordxex">lit-word!</a> <br><a href="./index.html#lit-wordxqm">lit-word?</a> <a href="./index.html#ll">ll</a> <a href="./index.html#load">load</a> <a href="./index.html#log-10">log-10</a> <br><a href="./index.html#log-2">log-2</a> <a href="./index.html#log-e">log-e</a> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#logicxqm">logic?</a> <br><a href="./index.html#loop">loop</a> <a href="./index.html#lowercase">lowercase</a> <a href="./index.html#ls">ls</a> <a href="./index.html#make">make</a> <br><a href="./index.html#make-dir">make-dir</a> <a href="./index.html#mapxex">map!</a> <a href="./index.html#mapxqm">map?</a> <a href="./index.html#math">math</a> <br><a href="./index.html#max">max</a> <a href="./index.html#min">min</a> <a href="./index.html#modify">modify</a> <a href="./index.html#modulo">modulo</a> <br><a href="./index.html#mold">mold</a> <a href="./index.html#move">move</a> <a href="./index.html#multiply">multiply</a> <a href="./index.html#NaN">NaN</a> <br><a href="./index.html#NaNxqm">NaN?</a> <a href="./index.html#nativexex">native!</a> <a href="./index.html#nativexqm">native?</a> <a href="./index.html#negate">negate</a> <br><a href="./index.html#negativexqm">negative?</a> <a href="./index.html#new-line">new-line</a> <a href="./index.html#new-linexqm">new-line?</a> <a href="./index.html#next">next</a> <br><a href="./index.html#no">no</a> <a href="./index.html#none">none</a> <a href="./index.html#nonexex">none!</a> <a href="./index.html#nonexqm">none?</a> <br><a href="./index.html#normalize-dir">normalize-dir</a> <a href="./index.html#not">not</a> <a href="./index.html#not-equalxqm">not-equal?</a> <a href="./index.html#now">now</a> <br><a href="./index.html#numberxex">number!</a> <a href="./index.html#object">object</a> <a href="./index.html#objectxex">object!</a> <a href="./index.html#objectxqm">object?</a> <br><a href="./index.html#oddxqm">odd?</a> <a href="./index.html#off">off</a> <a href="./index.html#on">on</a> <a href="./index.html#opxex">op!</a> <br><a href="./index.html#opxqm">op?</a> <a href="./index.html#or">or</a> <a href="./index.html#orxsn">or~</a> <a href="./index.html#pad">pad</a> <br><a href="./index.html#pairxex">pair!</a> <a href="./index.html#pairxqm">pair?</a> <a href="./index.html#parenxex">paren!</a> <a href="./index.html#parenxqm">paren?</a> <br><a href="./index.html#parse">parse</a> <a href="./index.html#parse-trace">parse-trace</a> <a href="./index.html#pathxex">path!</a> <a href="./index.html#pathxqm">path?</a> <br><a href="./index.html#percentxex">percent!</a> <a href="./index.html#percentxqm">percent?</a> <a href="./index.html#pi">pi</a> <a href="./index.html#pick">pick</a> <br><a href="./index.html#point">point</a> <a href="./index.html#pointxex">point!</a> <a href="./index.html#poke">poke</a> <a href="./index.html#positivexqm">positive?</a> <br><a href="./index.html#power">power</a> <a href="./index.html#prin">prin</a> <a href="./index.html#print">print</a> <a href="./index.html#probe">probe</a> <br><a href="./index.html#put">put</a> <a href="./index.html#pwd">pwd</a> <a href="./index.html#q">q</a> <a href="./index.html#quit">quit</a> <br><a href="./index.html#quit-return">quit-return</a> <a href="./index.html#quote">quote</a> <a href="./index.html#random">random</a> <a href="./index.html#reactxqm">react?</a> <br><a href="./index.html#read">read</a> <a href="./index.html#red-complete-file">red-complete-file</a> <a href="./index.html#red-complete-path">red-complete-path</a> <a href="./index.html#reduce">reduce</a> <br><a href="./index.html#refinementxex">refinement!</a> <a href="./index.html#refinementxqm">refinement?</a> <a href="./index.html#reflect">reflect</a> <a href="./index.html#remainder">remainder</a> <br><a href="./index.html#remove">remove</a> <a href="./index.html#remove-each">remove-each</a> <a href="./index.html#repeat">repeat</a> <a href="./index.html#repend">repend</a> <br><a href="./index.html#replace">replace</a> <a href="./index.html#request-dir">request-dir</a> <a href="./index.html#request-file">request-file</a> <a href="./index.html#request-font">request-font</a> <br><a href="./index.html#return">return</a> <a href="./index.html#reverse">reverse</a> <a href="./index.html#round">round</a> <a href="./index.html#routine">routine</a> <br><a href="./index.html#routinexex">routine!</a> <a href="./index.html#routinexqm">routine?</a> <a href="./index.html#samexqm">same?</a> <a href="./index.html#save">save</a> <br><a href="./index.html#second">second</a> <a href="./index.html#select">select</a> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#seriesxqm">series?</a> <br><a href="./index.html#set">set</a> <a href="./index.html#set-current-dir">set-current-dir</a> <a href="./index.html#set-env">set-env</a> <a href="./index.html#set-pathxex">set-path!</a> <br><a href="./index.html#set-pathxqm">set-path?</a> <a href="./index.html#set-quiet">set-quiet</a> <a href="./index.html#set-wordxex">set-word!</a> <a href="./index.html#set-wordxqm">set-word?</a> <br><a href="./index.html#shift">shift</a> <a href="./index.html#shift-left">shift-left</a> <a href="./index.html#shift-logical">shift-logical</a> <a href="./index.html#shift-right">shift-right</a> <br><a href="./index.html#sin">sin</a> <a href="./index.html#sine">sine</a> <a href="./index.html#skip">skip</a> <a href="./index.html#sort">sort</a> <br><a href="./index.html#source">source</a> <a href="./index.html#space">space</a> <a href="./index.html#spec-of">spec-of</a> <a href="./index.html#split">split</a> <br><a href="./index.html#split-path">split-path</a> <a href="./index.html#square-root">square-root</a> <a href="./index.html#stats">stats</a> <a href="./index.html#strict-equalxqm">strict-equal?</a> <br><a href="./index.html#stringxex">string!</a> <a href="./index.html#stringxqm">string?</a> <a href="./index.html#subtract">subtract</a> <a href="./index.html#suffixxqm">suffix?</a> <br><a href="./index.html#swap">swap</a> <a href="./index.html#switch">switch</a> <a href="./index.html#tagxex">tag!</a> <a href="./index.html#tagxqm">tag?</a> <br><a href="./index.html#tail">tail</a> <a href="./index.html#tailxqm">tail?</a> <a href="./index.html#take">take</a> <a href="./index.html#tan">tan</a> <br><a href="./index.html#tangent">tangent</a> <a href="./index.html#third">third</a> <a href="./index.html#throw">throw</a> <a href="./index.html#timexex">time!</a> <br><a href="./index.html#timexqm">time?</a> <a href="./index.html#to">to</a> <a href="./index.html#to-email">to-email</a> <a href="./index.html#to-hex">to-hex</a> <br><a href="./index.html#to-image">to-image</a> <a href="./index.html#to-local-file">to-local-file</a> <a href="./index.html#to-red-file">to-red-file</a> <a href="./index.html#to-tag">to-tag</a> <br><a href="./index.html#to-time">to-time</a> <a href="./index.html#trim">trim</a> <a href="./index.html#true">true</a> <a href="./index.html#try">try</a> <br><a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#tuplexqm">tuple?</a> <a href="./index.html#typexqm">type?</a> <a href="./index.html#typesetxex">typeset!</a> <br><a href="./index.html#typesetxqm">typeset?</a> <a href="./index.html#union">union</a> <a href="./index.html#unique">unique</a> <a href="./index.html#unless">unless</a> <br><a href="./index.html#unset">unset</a> <a href="./index.html#unsetxex">unset!</a> <a href="./index.html#unsetxqm">unset?</a> <a href="./index.html#until">until</a> <br><a href="./index.html#unview">unview</a> <a href="./index.html#uppercase">uppercase</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#urlxqm">url?</a> <br><a href="./index.html#valuexqm">value?</a> <a href="./index.html#values-of">values-of</a> <a href="./index.html#vectorxex">vector!</a> <a href="./index.html#vectorxqm">vector?</a> <br><a href="./index.html#view">view</a> <a href="./index.html#wait">wait</a> <a href="./index.html#what">what</a> <a href="./index.html#what-dir">what-dir</a> <br><a href="./index.html#while">while</a> <a href="./index.html#withinxqm">within?</a> <a href="./index.html#wordxex">word!</a> <a href="./index.html#wordxqm">word?</a> <br><a href="./index.html#words-of">words-of</a> <a href="./index.html#write">write</a> <a href="./index.html#xor">xor</a> <a href="./index.html#xorxsn">xor~</a> <br><a href="./index.html#yes">yes</a> <a href="./index.html#zeroxqm">zero?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="ix-cat">主要类别索引</h2><pre><a href="./index.html#cat-b01">数字基础</a> <a href="./index.html#cat-b02">位操作</a> <a href="./index.html#cat-b03">布尔</a> <br><a href="./index.html#cat-c01">生成类型</a> <a href="./index.html#cat-c02">比较</a> <a href="./index.html#cat-c03">条件分支</a> <br><a href="./index.html#cat-c04">控制台</a> <a href="./index.html#cat-c05">常量</a> <a href="./index.html#cat-c06">创建</a> <br><a href="./index.html#cat-c07">转换</a> <a href="./index.html#cat-c08">颜色</a> <a href="./index.html#cat-d01">目录</a> <br><a href="./index.html#cat-d02">文档</a> <a href="./index.html#cat-d03">数据类型</a> <a href="./index.html#cat-e01">错误</a> <br><a href="./index.html#cat-e02">评估</a> <a href="./index.html#cat-e03">退出</a> <a href="./index.html#cat-e04">事件</a> <br><a href="./index.html#cat-f01">文件</a> <a href="./index.html#cat-f02">格式化</a> <a href="./index.html#cat-f03">函数</a> <br><a href="./index.html#cat-g01">GUI (VID)</a> <a href="./index.html#cat-g02">GUI(VID)方言</a> <a href="./index.html#cat-h01">帮助 & 调试</a> <br><a href="./index.html#cat-i01">输入</a> <a href="./index.html#cat-i02">迭代</a> <a href="./index.html#cat-l01">逻辑</a> <br><a href="./index.html#cat-m01">图</a> <a href="./index.html#cat-m02">数学</a> <a href="./index.html#cat-n01">网络</a> <br><a href="./index.html#cat-o01">对象</a> <a href="./index.html#cat-o02">输出</a> <a href="./index.html#cat-p01">解析</a> <br><a href="./index.html#cat-p02">解析方言</a> <a href="./index.html#cat-r01">反射</a> <a href="./index.html#cat-s01">序列</a> <br><a href="./index.html#cat-s02">集合</a> <a href="./index.html#cat-s03">特殊目的</a> <a href="./index.html#cat-s04">字符串操作</a> <br><a href="./index.html#cat-s05">系统相关</a> <a href="./index.html#cat-t01">类型检查</a> <a href="./index.html#cat-u01">未知</a> <br><a href="./index.html#cat-u02">URL</a> <a href="./index.html#cat-w01">标识符操作</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-b01">分类: 数字基础</h2><pre><a href="./index.html#debase">debase</a> <a href="./index.html#enbase">enbase</a> <a href="./index.html#to-hex">to-hex</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-b02">分类: 位操作</h2><pre><a href="./index.html#xltxlt"><<</a> <a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> <a href="./index.html#and">and</a> <br><a href="./index.html#andxsn">and~</a> <a href="./index.html#complement">complement</a> <a href="./index.html#not">not</a> <a href="./index.html#or">or</a> <br><a href="./index.html#orxsn">or~</a> <a href="./index.html#shift">shift</a> <a href="./index.html#shift-left">shift-left</a> <a href="./index.html#shift-logical">shift-logical</a> <br><a href="./index.html#shift-right">shift-right</a> <a href="./index.html#xor">xor</a> <a href="./index.html#xorxsn">xor~</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-b03">分类: 布尔</h2><pre><a href="./index.html#all">all</a> <a href="./index.html#and">and</a> <a href="./index.html#andxsn">and~</a> <a href="./index.html#any">any</a> <br><a href="./index.html#false">false</a> <a href="./index.html#no">no</a> <a href="./index.html#none">none</a> <a href="./index.html#not">not</a> <br><a href="./index.html#off">off</a> <a href="./index.html#on">on</a> <a href="./index.html#or">or</a> <a href="./index.html#orxsn">or~</a> <br><a href="./index.html#true">true</a> <a href="./index.html#yes">yes</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c01">分类: 生成类型</h2><pre><a href="./index.html#as-color">as-color</a> <a href="./index.html#as-ipv4">as-ipv4</a> <a href="./index.html#as-pair">as-pair</a> <a href="./index.html#as-rgba">as-rgba</a> <br><a href="./index.html#to">to</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c02">分类: 比较</h2><pre><a href="./index.html#xlt"><</a> <a href="./index.html#xltxeq"><=</a> <a href="./index.html#xltxgt"><></a> <a href="./index.html#xeq">=</a> <br><a href="./index.html#xeqxeq">==</a> <a href="./index.html#xeqxqm">=?</a> <a href="./index.html#xgt">></a> <a href="./index.html#xgtxeq">>=</a> <br><a href="./index.html#all">all</a> <a href="./index.html#and">and</a> <a href="./index.html#andxsn">and~</a> <a href="./index.html#any">any</a> <br><a href="./index.html#equalxqm">equal?</a> <a href="./index.html#greater-or-equalxqm">greater-or-equal?</a> <a href="./index.html#greaterxqm">greater?</a> <a href="./index.html#lesser-or-equalxqm">lesser-or-equal?</a> <br><a href="./index.html#lesserxqm">lesser?</a> <a href="./index.html#negativexqm">negative?</a> <a href="./index.html#not">not</a> <a href="./index.html#not-equalxqm">not-equal?</a> <br><a href="./index.html#or">or</a> <a href="./index.html#orxsn">or~</a> <a href="./index.html#positivexqm">positive?</a> <a href="./index.html#samexqm">same?</a> <br><a href="./index.html#strict-equalxqm">strict-equal?</a> <a href="./index.html#zeroxqm">zero?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c03">分类: 条件分支</h2><pre><a href="./index.html#case">case</a> <a href="./index.html#catch">catch</a> <a href="./index.html#either">either</a> <a href="./index.html#if">if</a> <br><a href="./index.html#switch">switch</a> <a href="./index.html#throw">throw</a> <a href="./index.html#unless">unless</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c04">分类: 控制台</h2><pre><a href="./index.html#prin">prin</a> <a href="./index.html#print">print</a> <a href="./index.html#probe">probe</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c05">分类: 常量</h2><pre><a href="./index.html#false">false</a> <a href="./index.html#new-line">new-line</a> <a href="./index.html#no">no</a> <a href="./index.html#none">none</a> <br><a href="./index.html#on">on</a> <a href="./index.html#pi">pi</a> <a href="./index.html#space">space</a> <a href="./index.html#true">true</a> <br><a href="./index.html#yes">yes</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c06">分类: 创建</h2><pre><a href="./index.html#make">make</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c07">分类: 转换</h2><pre><a href="./index.html#as-color">as-color</a> <a href="./index.html#as-ipv4">as-ipv4</a> <a href="./index.html#as-pair">as-pair</a> <a href="./index.html#as-rgba">as-rgba</a> <br><a href="./index.html#debase">debase</a> <a href="./index.html#dehex">dehex</a> <a href="./index.html#dirize">dirize</a> <a href="./index.html#enbase">enbase</a> <br><a href="./index.html#form">form</a> <a href="./index.html#to">to</a> <a href="./index.html#to-email">to-email</a> <a href="./index.html#to-tag">to-tag</a> <br><a href="./index.html#to-time">to-time</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-c08">分类: 颜色</h2><pre><a href="./index.html#0aqua">aqua</a> <a href="./index.html#0beige">beige</a> <a href="./index.html#0black">black</a> <a href="./index.html#0blue">blue</a> <br><a href="./index.html#0brick">brick</a> <a href="./index.html#0brown">brown</a> <a href="./index.html#0coal">coal</a> <a href="./index.html#0coffee">coffee</a> <br><a href="./index.html#0crimson">crimson</a> <a href="./index.html#0cyan">cyan</a> <a href="./index.html#0forest">forest</a> <a href="./index.html#0gold">gold</a> <br><a href="./index.html#0gray">gray</a> <a href="./index.html#0green">green</a> <a href="./index.html#0ivory">ivory</a> <a href="./index.html#0khaki">khaki</a> <br><a href="./index.html#0leaf">leaf</a> <a href="./index.html#0linen">linen</a> <a href="./index.html#0magenta">magenta</a> <a href="./index.html#0maroon">maroon</a> <br><a href="./index.html#0mint">mint</a> <a href="./index.html#0navy">navy</a> <a href="./index.html#0oldrab">oldrab</a> <a href="./index.html#0olive">olive</a> <br><a href="./index.html#0orange">orange</a> <a href="./index.html#0papaya">papaya</a> <a href="./index.html#0pewter">pewter</a> <a href="./index.html#0pink">pink</a> <br><a href="./index.html#0purple">purple</a> <a href="./index.html#0reblue">reblue</a> <a href="./index.html#0rebolor">rebolor</a> <a href="./index.html#0red">red</a> <br><a href="./index.html#as-color">as-color</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-d01">分类: 目录</h2><pre><a href="./index.html#change-dir">change-dir</a> <a href="./index.html#clean-path">clean-path</a> <a href="./index.html#dir">dir</a> <a href="./index.html#dirxqm">dir?</a> <br><a href="./index.html#dirize">dirize</a> <a href="./index.html#existsxqm">exists?</a> <a href="./index.html#get-current-dir">get-current-dir</a> <a href="./index.html#list-dir">list-dir</a> <br><a href="./index.html#normalize-dir">normalize-dir</a> <a href="./index.html#pwd">pwd</a> <a href="./index.html#read">read</a> <a href="./index.html#red-complete-file">red-complete-file</a> <br><a href="./index.html#red-complete-path">red-complete-path</a> <a href="./index.html#request-dir">request-dir</a> <a href="./index.html#request-file">request-file</a> <a href="./index.html#split-path">split-path</a> <br><a href="./index.html#suffixxqm">suffix?</a> <a href="./index.html#to-local-file">to-local-file</a> <a href="./index.html#to-red-file">to-red-file</a> <a href="./index.html#write">write</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-d02">分类: 文档</h2><pre><a href="./index.html#xqm"></a> <a href="./index.html#xqmxqm">?</a> <a href="./index.html#comment">comment</a> <a href="./index.html#help">help</a> <br><a href="./index.html#source">source</a> <a href="./index.html#what">what</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-d03">分类: 数据类型</h2><pre><a href="./index.html#actionxex">action!</a> <a href="./index.html#any-listxex">any-list!</a> <a href="./index.html#any-objectxex">any-object!</a> <a href="./index.html#any-pathxex">any-path!</a> <br><a href="./index.html#any-stringxex">any-string!</a> <a href="./index.html#any-word">any-word</a> <a href="./index.html#binaryxex">binary!</a> <a href="./index.html#bitsetxex">bitset!</a> <br><a href="./index.html#blockxex">block!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#emailxex">email!</a> <br><a href="./index.html#errorxex">error!</a> <a href="./index.html#eventxex">event!</a> <a href="./index.html#filexex">file!</a> <a href="./index.html#floatxex">float!</a> <br><a href="./index.html#functionxex">function!</a> <a href="./index.html#get-pathxex">get-path!</a> <a href="./index.html#get-wordxex">get-word!</a> <a href="./index.html#hashxex">hash!</a> <br><a href="./index.html#imagexex">image!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#issuexex">issue!</a> <a href="./index.html#lit-pathxex">lit-path!</a> <br><a href="./index.html#lit-wordxex">lit-word!</a> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#make">make</a> <a href="./index.html#mapxex">map!</a> <br><a href="./index.html#nativexex">native!</a> <a href="./index.html#nonexex">none!</a> <a href="./index.html#numberxex">number!</a> <a href="./index.html#objectxex">object!</a> <br><a href="./index.html#opxex">op!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#parenxex">paren!</a> <a href="./index.html#pathxex">path!</a> <br><a href="./index.html#percentxex">percent!</a> <a href="./index.html#pointxex">point!</a> <a href="./index.html#refinementxex">refinement!</a> <a href="./index.html#routinexex">routine!</a> <br><a href="./index.html#seriesxex">series!</a> <a href="./index.html#set-pathxex">set-path!</a> <a href="./index.html#set-wordxex">set-word!</a> <a href="./index.html#stringxex">string!</a> <br><a href="./index.html#tagxex">tag!</a> <a href="./index.html#timexex">time!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#typesetxex">typeset!</a> <br><a href="./index.html#unsetxex">unset!</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#vectorxex">vector!</a> <a href="./index.html#wordxex">word!</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-e01">分类: 错误</h2><pre><a href="./index.html#attempt">attempt</a> <a href="./index.html#catch">catch</a> <a href="./index.html#cause-error">cause-error</a> <a href="./index.html#errorxqm">error?</a> <br><a href="./index.html#throw">throw</a> <a href="./index.html#try">try</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-e02">分类: 评估</h2><pre><a href="./index.html#also">also</a> <a href="./index.html#do">do</a> <a href="./index.html#do-safe">do-safe</a> <a href="./index.html#eval-set-path">eval-set-path</a> <br><a href="./index.html#reduce">reduce</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-e03">分类: 退出</h2><pre><a href="./index.html#exit">exit</a> <a href="./index.html#halt">halt</a> <a href="./index.html#q">q</a> <a href="./index.html#quit">quit</a> <br><a href="./index.html#quit-return">quit-return</a> <a href="./index.html#return">return</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-e04">分类: 事件</h2><pre><a href="./index.html#0on-alt-down">on-alt-down</a> <a href="./index.html#0on-alt-up">on-alt-up</a> <a href="./index.html#0on-aux-down">on-aux-down</a> <a href="./index.html#0on-aux-up">on-aux-up</a> <br><a href="./index.html#0on-change">on-change</a> <a href="./index.html#0on-click">on-click</a> <a href="./index.html#0on-close">on-close</a> <a href="./index.html#0on-create">on-create</a> <br><a href="./index.html#0on-dbl-click">on-dbl-click</a> <a href="./index.html#0on-detect">on-detect</a> <a href="./index.html#0on-down">on-down</a> <a href="./index.html#0on-drag">on-drag</a> <br><a href="./index.html#0on-drag-start">on-drag-start</a> <a href="./index.html#0on-drop">on-drop</a> <a href="./index.html#0on-enter">on-enter</a> <a href="./index.html#0on-face-deep-changexmu">on-face-deep-change*</a> <br><a href="./index.html#0on-focus">on-focus</a> <a href="./index.html#0on-key">on-key</a> <a href="./index.html#0on-key-down">on-key-down</a> <a href="./index.html#0on-key-up">on-key-up</a> <br><a href="./index.html#0on-menu">on-menu</a> <a href="./index.html#0on-mid-down">on-mid-down</a> <a href="./index.html#0on-mid-up">on-mid-up</a> <a href="./index.html#0on-move">on-move</a> <br><a href="./index.html#0on-moving">on-moving</a> <a href="./index.html#0on-over">on-over</a> <a href="./index.html#0on-pan">on-pan</a> <a href="./index.html#0on-parse-event">on-parse-event</a> <br><a href="./index.html#0on-press-tap">on-press-tap</a> <a href="./index.html#0on-resize">on-resize</a> <a href="./index.html#0on-resizing">on-resizing</a> <a href="./index.html#0on-rotate">on-rotate</a> <br><a href="./index.html#0on-select">on-select</a> <a href="./index.html#0on-time">on-time</a> <a href="./index.html#0on-two-tap">on-two-tap</a> <a href="./index.html#0on-unfocus">on-unfocus</a> <br><a href="./index.html#0on-up">on-up</a> <a href="./index.html#0on-zoom">on-zoom</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-f01">分类: 文件</h2><pre><a href="./index.html#cd">cd</a> <a href="./index.html#change-dir">change-dir</a> <a href="./index.html#clean-path">clean-path</a> <a href="./index.html#dir">dir</a> <br><a href="./index.html#dirxqm">dir?</a> <a href="./index.html#dirize">dirize</a> <a href="./index.html#existsxqm">exists?</a> <a href="./index.html#filexqm">file?</a> <br><a href="./index.html#get-current-dir">get-current-dir</a> <a href="./index.html#get-pathxqm">get-path?</a> <a href="./index.html#list-dir">list-dir</a> <a href="./index.html#ll">ll</a> <br><a href="./index.html#load">load</a> <a href="./index.html#ls">ls</a> <a href="./index.html#normalize-dir">normalize-dir</a> <a href="./index.html#pathxqm">path?</a> <br><a href="./index.html#read">read</a> <a href="./index.html#red-complete-file">red-complete-file</a> <a href="./index.html#red-complete-path">red-complete-path</a> <a href="./index.html#request-dir">request-dir</a> <br><a href="./index.html#request-file">request-file</a> <a href="./index.html#save">save</a> <a href="./index.html#set-current-dir">set-current-dir</a> <a href="./index.html#split-path">split-path</a> <br><a href="./index.html#suffixxqm">suffix?</a> <a href="./index.html#to-local-file">to-local-file</a> <a href="./index.html#to-red-file">to-red-file</a> <a href="./index.html#what-dir">what-dir</a> <br><a href="./index.html#write">write</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-f02">分类: 格式化</h2><pre><a href="./index.html#xqmxqm">?</a> <a href="./index.html#dehex">dehex</a> <a href="./index.html#form">form</a> <a href="./index.html#mold">mold</a> <br><a href="./index.html#pad">pad</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-f03">分类: 函数</h2><pre><a href="./index.html#body-of">body-of</a> <a href="./index.html#does">does</a> <a href="./index.html#exit">exit</a> <a href="./index.html#func">func</a> <br><a href="./index.html#function">function</a> <a href="./index.html#functionxex">function!</a> <a href="./index.html#has">has</a> <a href="./index.html#keys-of">keys-of</a> <br><a href="./index.html#nativexqm">native?</a> <a href="./index.html#routine">routine</a> <a href="./index.html#routinexex">routine!</a> <a href="./index.html#routinexqm">routine?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-g01">分类: GUI (VID)</h2><pre><a href="./index.html#0eventxqm">event?</a> <a href="./index.html#do-actor">do-actor</a> <a href="./index.html#do-events">do-events</a> <a href="./index.html#layout">layout</a> <br><a href="./index.html#unview">unview</a> <a href="./index.html#view">view</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-g02">分类: GUI(VID)方言</h2><pre><a href="./index.html#0across">across</a> <a href="./index.html#0all-over">all-over</a> <a href="./index.html#0aqua">aqua</a> <a href="./index.html#0area">area</a> <br><a href="./index.html#0at">at</a> <a href="./index.html#0beige">beige</a> <a href="./index.html#0below">below</a> <a href="./index.html#0black">black</a> <br><a href="./index.html#0blue">blue</a> <a href="./index.html#0bold">bold</a> <a href="./index.html#0bottom">bottom</a> <a href="./index.html#0brick">brick</a> <br><a href="./index.html#0brown">brown</a> <a href="./index.html#0button">button</a> <a href="./index.html#0center">center</a> <a href="./index.html#0center-face">center-face</a> <br><a href="./index.html#0check">check</a> <a href="./index.html#0check-all-reactions">check-all-reactions</a> <a href="./index.html#0check-reactions">check-reactions</a> <a href="./index.html#0coal">coal</a> <br><a href="./index.html#0coffee">coffee</a> <a href="./index.html#0crimson">crimson</a> <a href="./index.html#0cyan">cyan</a> <a href="./index.html#0data">data</a> <br><a href="./index.html#0default">default</a> <a href="./index.html#0disabled">disabled</a> <a href="./index.html#0do">do</a> <a href="./index.html#0draw">draw</a> <br><a href="./index.html#0drop-down">drop-down</a> <a href="./index.html#0drop-list">drop-list</a> <a href="./index.html#0dump-face">dump-face</a> <a href="./index.html#0extra">extra</a> <br><a href="./index.html#0facet">facet</a> <a href="./index.html#0field">field</a> <a href="./index.html#0find-flagxqm">find-flag?</a> <a href="./index.html#0focus">focus</a> <br><a href="./index.html#0font">font</a> <a href="./index.html#0font-color">font-color</a> <a href="./index.html#0font-name">font-name</a> <a href="./index.html#0font-size">font-size</a> <br><a href="./index.html#0forest">forest</a> <a href="./index.html#0gold">gold</a> <a href="./index.html#0gray">gray</a> <a href="./index.html#0green">green</a> <br><a href="./index.html#0hidden">hidden</a> <a href="./index.html#0insert-event-func">insert-event-func</a> <a href="./index.html#0italic">italic</a> <a href="./index.html#0ivory">ivory</a> <br><a href="./index.html#0khaki">khaki</a> <a href="./index.html#0leaf">leaf</a> <a href="./index.html#0left">left</a> <a href="./index.html#0linen">linen</a> <br><a href="./index.html#0link-sub-to-parent">link-sub-to-parent</a> <a href="./index.html#0link-tabs-to-parent">link-tabs-to-parent</a> <a href="./index.html#0loose">loose</a> <a href="./index.html#0magenta">magenta</a> <br><a href="./index.html#0maroon">maroon</a> <a href="./index.html#0middle">middle</a> <a href="./index.html#0mint">mint</a> <a href="./index.html#0navy">navy</a> <br><a href="./index.html#0needs">needs</a> <a href="./index.html#0no-wrap">no-wrap</a> <a href="./index.html#0offsetxqm">offset?</a> <a href="./index.html#0oldrab">oldrab</a> <br><a href="./index.html#0olive">olive</a> <a href="./index.html#0on-alt-down">on-alt-down</a> <a href="./index.html#0on-alt-up">on-alt-up</a> <a href="./index.html#0on-aux-down">on-aux-down</a> <br><a href="./index.html#0on-aux-up">on-aux-up</a> <a href="./index.html#0on-change">on-change</a> <a href="./index.html#0on-click">on-click</a> <a href="./index.html#0on-close">on-close</a> <br><a href="./index.html#0on-create">on-create</a> <a href="./index.html#0on-dbl-click">on-dbl-click</a> <a href="./index.html#0on-detect">on-detect</a> <a href="./index.html#0on-down">on-down</a> <br><a href="./index.html#0on-drag">on-drag</a> <a href="./index.html#0on-drag-start">on-drag-start</a> <a href="./index.html#0on-drop">on-drop</a> <a href="./index.html#0on-enter">on-enter</a> <br><a href="./index.html#0on-face-deep-changexmu">on-face-deep-change*</a> <a href="./index.html#0on-focus">on-focus</a> <a href="./index.html#0on-key">on-key</a> <a href="./index.html#0on-key-down">on-key-down</a> <br><a href="./index.html#0on-key-up">on-key-up</a> <a href="./index.html#0on-menu">on-menu</a> <a href="./index.html#0on-mid-down">on-mid-down</a> <a href="./index.html#0on-mid-up">on-mid-up</a> <br><a href="./index.html#0on-move">on-move</a> <a href="./index.html#0on-moving">on-moving</a> <a href="./index.html#0on-over">on-over</a> <a href="./index.html#0on-pan">on-pan</a> <br><a href="./index.html#0on-parse-event">on-parse-event</a> <a href="./index.html#0on-press-tap">on-press-tap</a> <a href="./index.html#0on-resize">on-resize</a> <a href="./index.html#0on-resizing">on-resizing</a> <br><a href="./index.html#0on-rotate">on-rotate</a> <a href="./index.html#0on-select">on-select</a> <a href="./index.html#0on-time">on-time</a> <a href="./index.html#0on-two-tap">on-two-tap</a> <br><a href="./index.html#0on-unfocus">on-unfocus</a> <a href="./index.html#0on-up">on-up</a> <a href="./index.html#0on-zoom">on-zoom</a> <a href="./index.html#0orange">orange</a> <br><a href="./index.html#0origin">origin</a> <a href="./index.html#0overlapxqm">overlap?</a> <a href="./index.html#0pad">pad</a> <a href="./index.html#0papaya">papaya</a> <br><a href="./index.html#0para">para</a> <a href="./index.html#0pewter">pewter</a> <a href="./index.html#0pink">pink</a> <a href="./index.html#0purple">purple</a> <br><a href="./index.html#0radio">radio</a> <a href="./index.html#0rate">rate</a> <a href="./index.html#0react">react</a> <a href="./index.html#0reblue">reblue</a> <br><a href="./index.html#0rebolor">rebolor</a> <a href="./index.html#0red">red</a> <a href="./index.html#0remove-event-func">remove-event-func</a> <a href="./index.html#0remove-reactor">remove-reactor</a> <br><a href="./index.html#0return">return</a> <a href="./index.html#0right">right</a> <a href="./index.html#0select">select</a> <a href="./index.html#0set-flag">set-flag</a> <br><a href="./index.html#0show">show</a> <a href="./index.html#0size-text">size-text</a> <a href="./index.html#0slider">slider</a> <a href="./index.html#0style">style</a> <br><a href="./index.html#0tab-panel">tab-panel</a> <a href="./index.html#0text">text</a> <a href="./index.html#0text-list">text-list</a> <a href="./index.html#0top">顶部</a> <br><a href="./index.html#0underline">underline</a> <a href="./index.html#0update-font-faces">update-font-faces</a> <a href="./index.html#0wrap">wrap</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-h01">分类: 帮助 & 调试</h2><pre><a href="./index.html#xqm"></a> <a href="./index.html#xqmxqm">?</a> <a href="./index.html#about">about</a> <a href="./index.html#help">help</a> <br><a href="./index.html#source">source</a> <a href="./index.html#what">what</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-i01">分类: 输入</h2><pre><a href="./index.html#ask">ask</a> <a href="./index.html#input">input</a> <a href="./index.html#last-lfxqm">last-lf?</a> <a href="./index.html#load">load</a> <br><a href="./index.html#read">read</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-i02">分类: 迭代</h2><pre><a href="./index.html#break">break</a> <a href="./index.html#continue">continue</a> <a href="./index.html#forall">forall</a> <a href="./index.html#foreach">foreach</a> <br><a href="./index.html#forever">forever</a> <a href="./index.html#loop">loop</a> <a href="./index.html#repeat">repeat</a> <a href="./index.html#until">until</a> <br><a href="./index.html#while">while</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-l01">分类: 逻辑</h2><pre><a href="./index.html#all">all</a> <a href="./index.html#and">and</a> <a href="./index.html#andxsn">and~</a> <a href="./index.html#any">any</a> <br><a href="./index.html#not">not</a> <a href="./index.html#or">or</a> <a href="./index.html#orxsn">or~</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-m01">分类: 图</h2><pre><a href="./index.html#extend">extend</a> <a href="./index.html#put">put</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-m02">分类: 数学</h2><pre><a href="./index.html#xpc">%</a> <a href="./index.html#xmu">*</a> <a href="./index.html#xmuxmu">**</a> <a href="./index.html#xpl">+</a> <br><a href="./index.html#-">-</a> <a href="./index.html#xsl">/</a> <a href="./index.html#xslxsl">//</a> <a href="./index.html#a-an">a-an</a> <br><a href="./index.html#absolute">absolute</a> <a href="./index.html#acos">acos</a> <a href="./index.html#add">add</a> <a href="./index.html#arccosine">arccosine</a> <br><a href="./index.html#arcsine">arcsine</a> <a href="./index.html#arctangent">arctangent</a> <a href="./index.html#arctangent2">arctangent2</a> <a href="./index.html#asin">asin</a> <br><a href="./index.html#atan">atan</a> <a href="./index.html#atan2">atan2</a> <a href="./index.html#cos">cos</a> <a href="./index.html#cosine">cosine</a> <br><a href="./index.html#divide">divide</a> <a href="./index.html#evenxqm">even?</a> <a href="./index.html#exp">exp</a> <a href="./index.html#log-10">log-10</a> <br><a href="./index.html#log-2">log-2</a> <a href="./index.html#log-e">log-e</a> <a href="./index.html#math">math</a> <a href="./index.html#max">max</a> <br><a href="./index.html#min">min</a> <a href="./index.html#modulo">modulo</a> <a href="./index.html#multiply">multiply</a> <a href="./index.html#NaN">NaN</a> <br><a href="./index.html#NaNxqm">NaN?</a> <a href="./index.html#negate">negate</a> <a href="./index.html#oddxqm">odd?</a> <a href="./index.html#pi">pi</a> <br><a href="./index.html#power">power</a> <a href="./index.html#random">random</a> <a href="./index.html#remainder">remainder</a> <a href="./index.html#round">round</a> <br><a href="./index.html#sin">sin</a> <a href="./index.html#sine">sine</a> <a href="./index.html#square-root">square-root</a> <a href="./index.html#subtract">subtract</a> <br><a href="./index.html#tan">tan</a> <a href="./index.html#tangent">tangent</a> <a href="./index.html#withinxqm">within?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-n01">分类: 网络</h2><pre><a href="./index.html#checksum">checksum</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-o01">分类: 对象</h2><pre><a href="./index.html#bind">bind</a> <a href="./index.html#construct">construct</a> <a href="./index.html#context">context</a> <a href="./index.html#extend">extend</a> <br><a href="./index.html#in">in</a> <a href="./index.html#object">object</a> <a href="./index.html#pathxex">path!</a> <a href="./index.html#pathxqm">path?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-o02">分类: 输出</h2><pre><a href="./index.html#last-lfxqm">last-lf?</a> <a href="./index.html#new-line">new-line</a> <a href="./index.html#new-linexqm">new-line?</a> <a href="./index.html#prin">prin</a> <br><a href="./index.html#print">print</a> <a href="./index.html#write">write</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-p01">分类: 解析</h2><pre><a href="./index.html#parse">parse</a> <a href="./index.html#parse-trace">parse-trace</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-p02">分类: 解析方言</h2><pre><a href="./index.html#1copy">copy</a> <a href="./index.html#1skip">skip</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-r01">分类: 反射</h2><pre><a href="./index.html#keys-of">keys-of</a> <a href="./index.html#reflect">reflect</a> <a href="./index.html#spec-of">spec-of</a> <a href="./index.html#values-of">values-of</a> <br><a href="./index.html#words-of">words-of</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-s01">分类: 序列</h2><pre><a href="./index.html#alter">alter</a> <a href="./index.html#append">append</a> <a href="./index.html#at">at</a> <a href="./index.html#back">back</a> <br><a href="./index.html#change">change</a> <a href="./index.html#clear">clear</a> <a href="./index.html#collect">collect</a> <a href="./index.html#compose">compose</a> <br><a href="./index.html#copy">copy</a> <a href="./index.html#emptyxqm">empty?</a> <a href="./index.html#exclude">exclude</a> <a href="./index.html#extract">extract</a> <br><a href="./index.html#fifth">fifth</a> <a href="./index.html#find">find</a> <a href="./index.html#first">first</a> <a href="./index.html#fourth">fourth</a> <br><a href="./index.html#head">head</a> <a href="./index.html#headxqm">head?</a> <a href="./index.html#indexxqm">index?</a> <a href="./index.html#insert">insert</a> <br><a href="./index.html#last">last</a> <a href="./index.html#lengthxqm">length?</a> <a href="./index.html#move">move</a> <a href="./index.html#next">next</a> <br><a href="./index.html#pathxex">path!</a> <a href="./index.html#pathxqm">path?</a> <a href="./index.html#pick">pick</a> <a href="./index.html#poke">poke</a> <br><a href="./index.html#remove">remove</a> <a href="./index.html#replace">replace</a> <a href="./index.html#reverse">reverse</a> <a href="./index.html#second">second</a> <br><a href="./index.html#select">select</a> <a href="./index.html#skip">skip</a> <a href="./index.html#sort">sort</a> <a href="./index.html#swap">swap</a> <br><a href="./index.html#tail">tail</a> <a href="./index.html#tailxqm">tail?</a> <a href="./index.html#take">take</a> <a href="./index.html#third">third</a> <br><a href="./index.html#union">union</a> <a href="./index.html#unique">unique</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-s02">分类: 集合</h2><pre><a href="./index.html#charset">charset</a> <a href="./index.html#difference">difference</a> <a href="./index.html#intersect">intersect</a> <a href="./index.html#union">union</a> <br><a href="./index.html#unique">unique</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-s03">分类: 特殊目的</h2><pre><a href="./index.html#also">also</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-s04">分类: 字符串操作</h2><pre><a href="./index.html#alter">alter</a> <a href="./index.html#append">append</a> <a href="./index.html#at">at</a> <a href="./index.html#back">back</a> <br><a href="./index.html#change">change</a> <a href="./index.html#clear">clear</a> <a href="./index.html#collect">collect</a> <a href="./index.html#compose">compose</a> <br><a href="./index.html#copy">copy</a> <a href="./index.html#emptyxqm">empty?</a> <a href="./index.html#exclude">exclude</a> <a href="./index.html#extract">extract</a> <br><a href="./index.html#fifth">fifth</a> <a href="./index.html#find">find</a> <a href="./index.html#first">first</a> <a href="./index.html#fourth">fourth</a> <br><a href="./index.html#head">head</a> <a href="./index.html#headxqm">head?</a> <a href="./index.html#indexxqm">index?</a> <a href="./index.html#insert">insert</a> <br><a href="./index.html#last">last</a> <a href="./index.html#lengthxqm">length?</a> <a href="./index.html#lowercase">lowercase</a> <a href="./index.html#move">move</a> <br><a href="./index.html#next">next</a> <a href="./index.html#pad">pad</a> <a href="./index.html#pick">pick</a> <a href="./index.html#poke">poke</a> <br><a href="./index.html#remove">remove</a> <a href="./index.html#replace">replace</a> <a href="./index.html#reverse">reverse</a> <a href="./index.html#second">second</a> <br><a href="./index.html#select">select</a> <a href="./index.html#skip">skip</a> <a href="./index.html#sort">sort</a> <a href="./index.html#split">split</a> <br><a href="./index.html#swap">swap</a> <a href="./index.html#tail">tail</a> <a href="./index.html#tailxqm">tail?</a> <a href="./index.html#third">third</a> <br><a href="./index.html#trim">trim</a> <a href="./index.html#uppercase">uppercase</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-s05">分类: 系统相关</h2><pre><a href="./index.html#call">call</a> <a href="./index.html#extract-boot-args">extract-boot-args</a> <a href="./index.html#flip-exe-flag">flip-exe-flag</a> <a href="./index.html#halt">halt</a> <br><a href="./index.html#quit">quit</a> <a href="./index.html#quit-return">quit-return</a> <a href="./index.html#stats">stats</a> <a href="./index.html#wait">wait</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-t01">分类: 类型检查</h2><pre><a href="./index.html#actionxqm">action?</a> <a href="./index.html#any-blockxqm">any-block?</a> <a href="./index.html#any-functionxqm">any-function?</a> <a href="./index.html#any-listxqm">any-list?</a> <br><a href="./index.html#any-objectxqm">any-object?</a> <a href="./index.html#any-pathxqm">any-path?</a> <a href="./index.html#any-stringxqm">any-string?</a> <a href="./index.html#any-wordxqm">any-word?</a> <br><a href="./index.html#binaryxqm">binary?</a> <a href="./index.html#bitsetxqm">bitset?</a> <a href="./index.html#blockxqm">block?</a> <a href="./index.html#charxqm">char?</a> <br><a href="./index.html#complementxqm">complement?</a> <a href="./index.html#contextxqm">context?</a> <a href="./index.html#datatypexqm">datatype?</a> <a href="./index.html#dirxqm">dir?</a> <br><a href="./index.html#emailxqm">email?</a> <a href="./index.html#emptyxqm">empty?</a> <a href="./index.html#equalxqm">equal?</a> <a href="./index.html#errorxqm">error?</a> <br><a href="./index.html#filexqm">file?</a> <a href="./index.html#floatxqm">float?</a> <a href="./index.html#functionxqm">function?</a> <a href="./index.html#get-pathxqm">get-path?</a> <br><a href="./index.html#get-wordxqm">get-word?</a> <a href="./index.html#hashxqm">hash?</a> <a href="./index.html#imagexqm">image?</a> <a href="./index.html#integerxqm">integer?</a> <br><a href="./index.html#issuexqm">issue?</a> <a href="./index.html#lit-pathxqm">lit-path?</a> <a href="./index.html#lit-wordxqm">lit-word?</a> <a href="./index.html#logicxqm">logic?</a> <br><a href="./index.html#mapxqm">map?</a> <a href="./index.html#nativexqm">native?</a> <a href="./index.html#new-linexqm">new-line?</a> <a href="./index.html#nonexqm">none?</a> <br><a href="./index.html#not-equalxqm">not-equal?</a> <a href="./index.html#objectxqm">object?</a> <a href="./index.html#opxqm">op?</a> <a href="./index.html#pairxqm">pair?</a> <br><a href="./index.html#parenxqm">paren?</a> <a href="./index.html#pathxqm">path?</a> <a href="./index.html#percentxqm">percent?</a> <a href="./index.html#point">point</a> <br><a href="./index.html#refinementxqm">refinement?</a> <a href="./index.html#routinexqm">routine?</a> <a href="./index.html#samexqm">same?</a> <a href="./index.html#seriesxqm">series?</a> <br><a href="./index.html#set-pathxqm">set-path?</a> <a href="./index.html#set-wordxqm">set-word?</a> <a href="./index.html#stringxqm">string?</a> <a href="./index.html#tagxqm">tag?</a> <br><a href="./index.html#timexqm">time?</a> <a href="./index.html#tuplexqm">tuple?</a> <a href="./index.html#typexqm">type?</a> <a href="./index.html#typesetxqm">typeset?</a> <br><a href="./index.html#urlxqm">url?</a> <a href="./index.html#valuexqm">value?</a> <a href="./index.html#vectorxqm">vector?</a> <a href="./index.html#wordxqm">word?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-u01">分类: 未知</h2><pre><a href="./index.html#browse">browse</a> <a href="./index.html#clear-reactions">clear-reactions</a> <a href="./index.html#create-dir">create-dir</a> <a href="./index.html#default-input-completer">default-input-completer</a> <br><a href="./index.html#do-file">do-file</a> <a href="./index.html#dump-reactions">dump-reactions</a> <a href="./index.html#get-env">get-env</a> <a href="./index.html#list-env">list-env</a> <br><a href="./index.html#make-dir">make-dir</a> <a href="./index.html#modify">modify</a> <a href="./index.html#now">now</a> <a href="./index.html#reactxqm">react?</a> <br><a href="./index.html#remove-each">remove-each</a> <a href="./index.html#repend">repend</a> <a href="./index.html#request-font">request-font</a> <a href="./index.html#routine">routine</a> <br><a href="./index.html#set-env">set-env</a> <a href="./index.html#set-quiet">set-quiet</a> <a href="./index.html#to-image">to-image</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-u02">分类: URL</h2><pre><a href="./index.html#pathxex">path!</a> <a href="./index.html#pathxqm">path?</a> <a href="./index.html#read">read</a> <a href="./index.html#urlxex">url!</a> <br><a href="./index.html#urlxqm">url?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><h2 id="cat-w01">分类: 标识符操作</h2><pre><a href="./index.html#get">get</a> <a href="./index.html#quote">quote</a> <a href="./index.html#set">set</a> <a href="./index.html#unset">unset</a> <br><a href="./index.html#unsetxex">unset!</a> <a href="./index.html#unsetxqm">unset?</a> </pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="xpc"> %</span> 类型: op! 分类: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xpc">%</a>返回当参数 1 被 <br>参数 2 相除的结果。<br><br>参数可以是这些类型:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a> <a href="./index.html#timexex">time!</a><br></pre>例子<pre>red>> 3 % 2<br>== 1<br><br>red>> 3.5 % 2<br>== 1.5<br><br>red>> 3.6 % 2.2<br>== 1.4<br><br>red>> 11x19 % 3<br>== 2x1<br><br>red>> 11x19 % 3x4<br>== 2x3<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xmu"> *</span> 类型: op! 分类: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xmu">*</a>将其两个操作数相乘。<br>这等价于 <a href="./index.html#multiply">multiply</a>函数。<br><br>它适用于以下类型:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>在 Red 语言中,中缀运算符从左到右进行运算,没有优先级。<br>您可以使用括号 () 来更改运算顺序。<br><br>关键字 <a href="./index.html#xmu">*</a> 是一个 Red 关键字,因此需要用空格分隔开来。<br><br>通常,结果的类型与第一个操作数的类型相同,<br>这是明智的。 当类型不兼容时会导致错误。<br><br>注意不同长度的矢量相乘时的结果。<br><br>当我们相乘两个 <a href="./index.html#vectorxex">vector!</a> 结果是一个重新分配的 <a href="./index.html#vectorxex">vector!</a>.<br><br>当我们乘以一个<a href="./index.html#vectorxex">vector!</a>以及一个<a href="./index.html#numberxex">number!</a>, 原本的<a href="./index.html#vectorxex">vector!</a> <br>将被修改。<br></pre>例子<pre>red>> 2 * 3.7<br>== 7.4<br><br>red>> 3 * 1.4.8<br>== 1.12.8<br><br>red>> 4 * 10x20<br>== 40x80<br><br>red>> v1: make vector![2 3 4 5]<br>== make vector! [2 3 4 5]<br><br>red>> v2: make vector! [22 55]<br>== make vector! [22 55]<br><br>red>> v1 * v2<br>== make vector! [44 165]<br><br>red>> v1<br>== make vector! [2 3 4 5]<br><b style="color: green">; v1 没有改变</b><br><br>red>> v1 * 9<br>== make vector! [18 27 36 45]<br><br>red>> v1<br>== make vector! [18 27 36 45]<br><b style="color: green">; v1 改变了</b><br><br>red>> 3 * v1<br>*** 脚本错误:这里不允许使用矢量类型<br>*** 位置:*<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xmuxmu"> **</span> type: op! 分类: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xmuxmu">**</a>参数 1 的 参数 2 次幂。<br></pre>例子<pre>red>> 2 ** 2<br>== 4<br><br>red>> 2 ** 10<br>== 1024<br><br>red>> 2 ** -1<br>== 0.5<br><br>red>> 2 ** -10<br>== 0.0009765625<br><br>red>> -2 ** 4<br>== 16<br><br>red>> -2 ** 3<br>== -8<br><br>red>> 2 ** 0.5<br>== 1.414213562373095<br><br>red>> 2 ** -0.5<br>== 0.7071067811865476<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xpl"> +</span> 类型: op! 分类: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xpl">+</a>两个操作数相加。<br>这等价于 <a href="./index.html#add">add</a>函数。<br><br>它适用于以下类型:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>在 Red 语言中,中缀运算符从左到右进行运算,没有优先级。<br>您可以使用括号 () 来更改运算顺序。<br><br>通常,结果的类型与第一个操作数的类型相同,<br>这是明智的。 当类型不兼容时会导致错误。<br>参见例子。<br><br>注意不同长度的矢量相加时的结果。<br><br>操作符<a href="./index.html#xpl">+</a> 是一个 Red 关键字,因此需要用空格分隔开来。<br><br>当我们对两个 <a href="./index.html#vectorxex">vector!</a> 结果是一个重新分配的 <a href="./index.html#vectorxex">vector!</a>.<br>当我们加上一个 <a href="./index.html#numberxex">number!</a> 到一个 <a href="./index.html#vectorxex">vector!</a>, 原本的<a href="./index.html#vectorxex">vector!</a> 将被修改。<br></pre>例子<pre>red>> 1 + 3.7<br>== 4.7<br><br>red>> 3 + 100x200<br>== 103x203<br><br>red>> v1: make Vector![3 2 1 4]<br>== make vector! [3 2 1 4]<br><br>red>> v2: make vector![100 200]<br>== make vector! [100 200]<br><br>red>> v1 + v2<br>== make vector! [103 202]<br><br>red>> v1<br>== make vector! [3 2 1 4]<br><b style="color: green">; v1 没有改变</b><br><br>red>> v2 + v1<br>== make vector! [103 202]<br><br>red>> v1 - 22<br>== make vector! [-19 -20 -21 -18]<br><b style="color: green">; v1 改变了</b><br><br>red>> v1<br>== make vector! [-19 -20 -21 -18]<br><br>red>> 3 + v1<br>*** 脚本错误:这里不允许使用矢量类型<br>*** 位置:+<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="-"> -</span> 类型: op! 分类: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#-">-</a>从第一个操作数中减去第二个操作数。<br>这等价于 <a href="./index.html#subtract">subtract</a>函数。<br><br>它适用于以下类型:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>在 Red 语言中,中缀运算符从左到右进行运算,没有优先级。<br>您可以使用括号 () 来更改运算顺序。<br><br>操作符<a href="./index.html#-">-</a> 是一个 Red 关键字,因此需要用空格分隔开来。<br><br>通常,结果的类型与第一个操作数的类型相同,<br>这是明智的。 当类型不兼容时会导致错误。<br><br>注意不同长度的矢量相减时的结果。<br><br>当我们减去两个向量时,结果是一个新分配的向量。<br>当我们从一个向量中减去一个数字时,原始向量将被修改。<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Subtract <a href="./index.html#floatxex">float!</a> from <a href="./index.html#integerxex">integer!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> 3 - 1.4<br>1.6<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Subtract <a href="./index.html#pairxex">pair!</a> from <a href="./index.html#integerxex">integer!</a> not possible</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> 3 - 100x100<br>*** Script error: - does not allow pair for its value2 argument<br>*** Where: -<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Subtract <a href="./index.html#integerxex">integer!</a> from <a href="./index.html#pairxex">pair!</a> is possible</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> 100x200 - 3<br>== 97x197<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Subtract <a href="./index.html#vectorxex">vector!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> v1: make vector! [3 2 1 4]<br>== make vector! [3 2 1 4]<br><br>red>> v2: make vector! [100 200]<br>== make vector! [100 200]<br><br>red>> v1 - v2<br>== make vector! [-97 -198]<br><br>red>> v2 - v1<br>== make vector! [97 198]<br><br>red>> v2<br>== make vector! [100 200]<br><b style="color: green">; v2 is unchanged</b><br><br>red>> v1 - 22<br>== make vector! [-19 -20 -21 -18]<br><br>red>> v1<br>== make vector! [-19 -20 -21 -18]<br><b style="color: green">; v1 is altered!</b><br><br>red>> 22 - v1<br>*** 脚本错误:这里不允许使用矢量类型<br>*** Where: -<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xsl"> /</span> type: op! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xsl">/</a> divides its operands giving a quotient.<br>这等价于 <a href="./index.html#divide">divide</a>函数。<br><br>它适用于以下类型:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>在 Red 语言中,中缀运算符从左到右进行运算,没有优先级。<br>您可以使用括号 () 来更改运算顺序。<br><br><a href="./index.html#xsl">/</a> 是一个 Red 关键字,因此需要用空格分隔开来。<br><br>When one of the operands is a <a href="./index.html#floatxex">float!</a>, the result is a <a href="./index.html#floatxex">float!</a>.<br><br>When both operands are <a href="./index.html#integerxex">integer!</a>, the result is <a href="./index.html#integerxex">integer!</a>,<br>truncated towards zero.<br><br>Otherwise, the type of the result is the same type as the first operand,<br>这是明智的。 当类型不兼容时会导致错误。<br><br>Note the result when <a href="./index.html#vectorxex">vector!</a>s of different lengths are divided.<br><br>When we divide two <a href="./index.html#vectorxex">vector!</a> 结果是一个重新分配的 <a href="./index.html#vectorxex">vector!</a>.<br>When we divide a <a href="./index.html#vectorxex">vector!</a> by a <a href="./index.html#numberxex">number!</a>, 原本的<a href="./index.html#vectorxex">vector!</a> 将被修改。<br></pre>例子<pre>red>> 9 / 3<br>== 3<br><br>red>> 9.0 / 3<br>== 3.0<br><br>red>> 10 / 11<br>== 0<br><br>red>> -11 / 4<br>== -2<br><br>red>> 100x30 / 5<br>== 20x6<br><br>red>> 100x40 / 2x4<br>== 50x10<br><br>red>> 3.9.19 / 3<br>== 1.3.6<br><br>red>> v1: make vector![100 200 300 400]<br>== make vector! [100 200 300 400]<br><br>red>> v2: make vector![5 5 10]<br>== make vector! [5 5 10]<br><br>red>> v1 / v2<br>== make vector! [20 40 30]<br><br>red>> v1<br>== make vector! [100 200 300 400]<br><b style="color: green">; v1 没有改变</b><br><br>red>> v1 / 5<br>== make vector! [20 40 60 80]<br><br>red>> v1<br>== make vector! [20 40 60 80]<br><b style="color: green">; v1 改变了</b><br><br>red>> 5 / v1<br>*** 脚本错误:这里不允许使用矢量类型<br>*** Where: /<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xslxsl"> //</span> type: op! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>中缀词<a href="./index.html#xslxsl">//</a> is the nonnegative remainder oparator,<br>that returns what is left over when the first argument is divided <br>by the second.<br><br>Has two arguments of type:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>There is also a functional version, named <a href="./index.html#remainder">remainder</a>.<br><br>If the first argument is positive, then the remainder is positive.<br><br>If the first argument is negative, then the remainder is also positive,<br>as in -5 <a href="./index.html#xslxsl">//</a> 4, which results in 3.<br><br>If the first argument is zero, then the remainder is also zero.<br><br>If the second argument is zero, a run-time error occurs.<br></pre>例子<pre>red>> 5 // 4<br>== 1<br>red>> 5 // 5<br>== 0<br>red>> 5 // 6<br>== 5<br>red>> -5 // 4<br>== 3<br>red>> 10 // 3.3<br>== 0.1000000000000005<br>red>> 5x10 // 4<br>*** Internal error: reserved for future use (or not yet implemented)<br>*** Where: ><br>red>> remainder 5x10 4<br>== 1x2<br>red>> make vector![5 5 10] // 4<br>*** Script error: % does not allow block for its value1 argument<br>*** Where: %<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0across"> across</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0across">across</a> is used to position GUI elements following that<br>word at the right hand side of the previous GUI element.<br></pre>例子<pre>Red [<br> needs: 'view<br>]<br><br>view [<br> across<br> text "Line 1"<br> text "Line 2"<br>]<br><br><img src="./index_files/vid-across.png" alt="vid-across.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0all-over"> all-over</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0aqua"> aqua</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0aqua">aqua</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 40.100.130<br></pre>例子<pre>view [<br> text 100x50 aqua " "<br>]<br><br><img src="./index_files/vid-aqua.png" alt="vid-aqua.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0area"> area</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0at"> at</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0beige"> beige</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0beige">beige</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.228.196<br></pre>例子<pre>view [<br> text 100x50 beige " "<br>]<br><br><img src="./index_files/vid-beige.png" alt="vid-beige.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0below"> below</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The function <a href="./index.html#below">below</a> is used to position GUI elements following that<br>word below the previous GUI element.<br></pre>例子<pre>Red [<br> needs: 'view<br>]<br><br>view [<br> below<br> text "Line 1"<br> text "Line 2"<br>]<br><br><img src="./index_files/vid-below.png" alt="vid-below.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0black"> black</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0black">black</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.0.0<br></pre>例子<pre>view [<br> text 100x50 black " "<br>]<br><br><img src="./index_files/vid-black.png" alt="vid-black.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0blue"> blue</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0blue">blue</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.0.255<br></pre>例子<pre>view [<br> text 100x50 blue " "<br>]<br><br><img src="./index_files/vid-blue.png" alt="vid-blue.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0bold"> bold</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0bottom"> bottom</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0brick"> brick</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0brick">brick</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 178.34.34<br></pre>例子<pre>view [<br> text 100x50 brick " "<br>]<br><br><img src="./index_files/vid-brick.png" alt="vid-brick.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0brown"> brown</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0brown">brown</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 139.69.19<br></pre>例子<pre>view [<br> text 100x50 brown " "<br>]<br><br><img src="./index_files/vid-brown.png" alt="vid-brown.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0button"> button</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0button">button</a> is a widget (a GUI element).<br><br>A button can have several properties:<br> - text<br> - image<br> <br>A button has associated actions like:<br> - on-down (mouse pressed)<br> - on-up (mouse released)<br> - on-click (mouse pressed)<br> - on-over (mouse hovers over the button)<br><br>For comprehensive documentation on VID look here: <a href="./vid.html">vid</a>.<br> <br></pre>例子<pre>Red [<br> needs: 'view<br>]<br><br>view [<br> button blue 300x30 "Click Me!"<br> on-up [print "Mouse up!"]<br> on-down [print "Mouse down!"]<br> on-click [print "Mouse clicked!"]<br> on-over [print "Mouse over me!"]<br>]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0center"> center</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0center-face"> center-face</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0check"> check</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0check-all-reactions"> check-all-reactions</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0check-reactions"> check-reactions</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0coal"> coal</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0coal">coal</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 64.64.64<br></pre>例子<pre>view [<br> text 100x50 coal " "<br>]<br><br><img src="./index_files/vid-coal.png" alt="vid-coal.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0coffee"> coffee</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0coffee">coffee</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 76.26.0<br></pre>例子<pre>view [<br> text 100x50 coffee " "<br>]<br><br><img src="./index_files/vid-coffee.png" alt="vid-coffee.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0crimson"> crimson</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0crimson">crimson</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 220.20.60<br></pre>例子<pre>view [<br> text 100x50 crimson " "<br>]<br><br><img src="./index_files/vid-crimson.png" alt="vid-crimson.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0cyan"> cyan</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0cyan">cyan</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.255.255<br></pre>例子<pre>view [<br> text 100x50 cyan " "<br>]<br><br><img src="./index_files/vid-cyan.png" alt="vid-cyan.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0data"> data</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0default"> default</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0disabled"> disabled</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0do"> do</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0draw"> draw</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0drop-down"> drop-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0drop-list"> drop-list</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0dump-face"> dump-face</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0eventxqm"> event?</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0extra"> extra</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0facet"> facet</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0field"> field</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0find-flagxqm"> find-flag?</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0focus"> focus</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0font"> font</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0font-color"> font-color</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0font-name"> font-name</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0font-size"> font-size</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0forest"> forest</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0forest">forest</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.48.0<br></pre>例子<pre>view [<br> text 100x50 forest " "<br>]<br><br><img src="./index_files/vid-forest.png" alt="vid-forest.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0gold"> gold</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0gold">gold</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.205.40<br></pre>例子<pre>view [<br> text 100x50 gold " "<br>]<br><br><img src="./index_files/vid-gold.png" alt="vid-gold.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0gray"> gray</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0gray">gray</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 128.128.128<br></pre>例子<pre>view [<br> text 100x50 gray " "<br>]<br><br><img src="./index_files/vid-gray.png" alt="vid-gray.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0green"> green</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0green">green</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.255.0<br></pre>例子<pre>view [<br> text 100x50 green " "<br>]<br><br><img src="./index_files/vid-green.png" alt="vid-green.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0hidden"> hidden</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0insert-event-func"> insert-event-func</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0italic"> italic</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0ivory"> ivory</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0ivory">ivory</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.255.240<br></pre>例子<pre>view [<br> text 100x50 ivory " "<br>]<br><br><img src="./index_files/vid-ivory.png" alt="vid-ivory.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0khaki"> khaki</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0khaki">khaki</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 179.179.126<br></pre>例子<pre>view [<br> text 100x50 khaki " "<br>]<br><br><img src="./index_files/vid-khaki.png" alt="vid-khaki.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0leaf"> leaf</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0leaf">leaf</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.128.0<br></pre>例子<pre>view [<br> text 100x50 leaf " "<br>]<br><br><img src="./index_files/vid-leaf.png" alt="vid-leaf.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0left"> left</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0linen"> linen</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0linen">linen</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 250.240.230<br></pre>例子<pre>view [<br> text 100x50 linen " "<br>]<br><br><img src="./index_files/vid-linen.png" alt="vid-linen.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0link-sub-to-parent"> link-sub-to-parent</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0link-tabs-to-parent"> link-tabs-to-parent</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0loose"> loose</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0magenta"> magenta</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0magenta">magenta</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.0.255<br></pre>例子<pre>view [<br> text 100x50 magenta " "<br>]<br><br><img src="./index_files/vid-magenta.png" alt="vid-magenta.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0maroon"> maroon</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0maroon">maroon</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 128.0.0<br></pre>例子<pre>view [<br> text 100x50 maroon " "<br>]<br><br><img src="./index_files/vid-maroon.png" alt="vid-maroon.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0middle"> middle</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0mint"> mint</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0mint">mint</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 100.136.116<br></pre>例子<pre>view [<br> text 100x50 mint " "<br>]<br><br><img src="./index_files/vid-mint.png" alt="vid-mint.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0navy"> navy</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0navy">navy</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 0.0.128<br></pre>例子<pre>view [<br> text 100x50 navy " "<br>]<br><br><img src="./index_files/vid-navy.png" alt="vid-navy.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0needs"> needs</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The get-word <a href="./index.html#needs">needs</a> is needed in the header block of a Red program<br>when you are going to use VID, the graphical interface manager.<br><br>Note the quote preceding the word <a href="./index.html#view">view</a>.<br></pre>例子<pre>Red [<br> title: "Create a GUI program"<br> needs: 'view<br>]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0no-wrap"> no-wrap</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0offsetxqm"> offset?</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0oldrab"> oldrab</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0oldrab">oldrab</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 72.72.16<br></pre>例子<pre>view [<br> text 100x50 oldrab " "<br>]<br><br><img src="./index_files/vid-oldrab.png" alt="vid-oldrab.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0olive"> olive</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0olive">olive</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 128.128.0<br></pre>例子<pre>view [<br> text 100x50 olive " "<br>]<br><br><img src="./index_files/vid-olive.png" alt="vid-olive.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0on-alt-down"> on-alt-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-alt-up"> on-alt-up</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-aux-down"> on-aux-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-aux-up"> on-aux-up</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-change"> on-change</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-click"> on-click</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-close"> on-close</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-create"> on-create</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-dbl-click"> on-dbl-click</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-detect"> on-detect</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-down"> on-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-drag"> on-drag</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-drag-start"> on-drag-start</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-drop"> on-drop</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-enter"> on-enter</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-face-deep-changexmu"> on-face-deep-change*</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-focus"> on-focus</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-key"> on-key</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-key-down"> on-key-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-key-up"> on-key-up</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-menu"> on-menu</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-mid-down"> on-mid-down</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-mid-up"> on-mid-up</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-move"> on-move</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-moving"> on-moving</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-over"> on-over</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-pan"> on-pan</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-parse-event"> on-parse-event</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-press-tap"> on-press-tap</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-resize"> on-resize</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-resizing"> on-resizing</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-rotate"> on-rotate</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-select"> on-select</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-time"> on-time</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-two-tap"> on-two-tap</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-unfocus"> on-unfocus</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-up"> on-up</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0on-zoom"> on-zoom</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-e04">事件</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0orange"> orange</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0orange">orange</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.150.10<br></pre>例子<pre>view [<br> text 100x50 orange " "<br>]<br><br><img src="./index_files/vid-orange.png" alt="vid-orange.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0origin"> origin</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0overlapxqm"> overlap?</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0pad"> pad</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0papaya"> papaya</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0papaya">papaya</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.80.37<br></pre>例子<pre>view [<br> text 100x50 papaya " "<br>]<br><br><img src="./index_files/vid-papaya.png" alt="vid-papaya.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0para"> para</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0pewter"> pewter</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0pewter">pewter</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 170.170.170<br></pre>例子<pre>view [<br> text 100x50 pewter " "<br>]<br><br><img src="./index_files/vid-pewter.png" alt="vid-pewter.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0pink"> pink</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0pink">pink</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.164.200<br></pre>例子<pre>view [<br> text 100x50 pink " "<br>]<br><br><img src="./index_files/vid-pink.png" alt="vid-pink.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0purple"> purple</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0purple">purple</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 128.0.128<br></pre>例子<pre>view [<br> text 100x50 purple " "<br>]<br><br><img src="./index_files/vid-purple.png" alt="vid-purple.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0radio"> radio</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0rate"> rate</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0react"> react</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0reblue"> reblue</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0reblue">reblue</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 38.58.108<br></pre>例子<pre>view [<br> text 100x50 reblue " "<br>]<br><br><img src="./index_files/vid-reblue.png" alt="vid-reblue.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0rebolor"> rebolor</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0rebolor">rebolor</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 142.128.110<br></pre>例子<pre>view [<br> text 100x50 rebolor " "<br>]<br><br><img src="./index_files/vid-rebolor.png" alt="vid-rebolor.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0red"> red</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-c08">颜色</a>, <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#0red">red</a> is a color that can be used for GUI elements.<br><br>It is a <a href="./index.html#tuplexex">tuple!</a> of value 255.0.0<br></pre>例子<pre>view [<br> text 100x50 red " "<br>]<br><br><img src="./index_files/vid-red.png" alt="vid-red.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0remove-event-func"> remove-event-func</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0remove-reactor"> remove-reactor</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0return"> return</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>The VID dialect word <a href="./index.html#xexreturn">!return</a> is used to position the next GUI<br>elements from the left side of the window.<br></pre>例子<pre>Red [<br> needs: 'view<br>]<br><br>view [<br> across<br> text "Line 1"<br> text "Line 2"<br> return<br> text "Line 3"<br>]<br><br><img src="./index_files/vid-return.png" alt="vid-return.png"><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="0right"> right</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0select"> select</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0set-flag"> set-flag</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0show"> show</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0size-text"> size-text</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0slider"> slider</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0style"> style</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0tab-panel"> tab-panel</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0text"> text</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0text-list"> text-list</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0top"> top</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0underline"> underline</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0update-font-faces"> update-font-faces</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="0wrap"> wrap</span> type: "GUI (VID) dialect"! Categories: <a href="./index.html#cat-g02">GUI(VID)方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="1copy"> copy</span> type: "Parse dialect"! Categories: <a href="./index.html#cat-p02">解析方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="1skip"> skip</span> type: "Parse dialect"! Categories: <a href="./index.html#cat-p02">解析方言</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="xlt"> <</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xlt"><</a> loosely compares operands on its left and right side and<br>returns <a href="./index.html#true">true</a> if the operand on the left is smaller than the operand on the right.<br>Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any <a href="./index.html#datatypexex">datatype!</a>.<br><br>Loose comparison means that:<br> - the case of strings is ignored when comparing<br> - same numeric values for different datatypes are considered equal<br></pre>例子<pre>2 < 3<br>== true<br><br>2 < 2.0<br>== false<br><br>22-03-2000 < 14-04-2012<br>== true<br><br>"ABC" < "abc"<br>== false<br><br>"abc" < "ABC"<br>== false<br><br>"abc" = "ABC"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xltxlt"> <<</span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#xltxlt"><<</a> shifts its first argument (an <a href="./index.html#integerxex">integer!</a>) to the left<br>by the number of bits in its second argument (also an <a href="./index.html#integerxex">integer!</a>).<br><br>The sign is taken into account.<br></pre>例子<pre>red>> to-hex 6<br>== #00000006<br><br>red>> to-hex 6 << 1<br>== #0000000C<br><br>red>> to-hex 6 << 2<br>== #00000018<br><br>red>> to-hex 6 << 3<br>== #00000030<br><br>red>> to-hex 6 << 4<br>== #00000060<br><br>red>> to-hex -6<br>== #FFFFFFFA<br><br>red>> to-hex -6 << 1<br>== #FFFFFFF4<br><br>red>> to-hex -6 << 2<br>== #FFFFFFE8<br><br>red>> to-hex -6 << 3<br>== #FFFFFFD0<br><br>red>> to-hex -6 << 4<br>== #FFFFFFA0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xltxeq"> <=</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xltxeq"><=</a> loosely compares operands on its left and right side and<br>returns <a href="./index.html#true">true</a> if the operand on the left is smaller than or equal to the operand<br>on the right. Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any <a href="./index.html#datatypexex">datatype!</a>.<br><br>Loose comparison means that:<br> - the case of strings is ignored when comparing<br> - same numeric values for different datatypes are considered equal<br></pre>例子<pre>2 <= 3<br>== true<br><br>2 <= 2.0<br>== true<br><br>22-03-2000 <= 14-04-2012<br>== true<br><br>"ABC" <= "abc"<br>== true<br><br>"abc" <= "ABC"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xltxgt"> <></span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xltxgt"><></a> compares 2 values, and returns <a href="./index.html#true">true</a> if they are<br>NOT equal, otherwise <a href="./index.html#false">false</a>.<br><br>The 2 values need not be of the same <a href="./index.html#datatypexex">datatype!</a>.<br>It is equivalent to the <a href="./index.html#not-equalxqm">not-equal?</a>函数。<br><br>Note that <a href="./index.html#stringxex">string!</a> values which only differ in case are considered equal.<br><br>Red also has a <a href="./index.html#strict-equalxqm">strict-equal?</a> function, where the types must be the same,<br>and <a href="./index.html#stringxex">string!</a> case is checked.<br></pre>例子<pre>red>> a: 33<br>== 33<br><br>red>> a <> 35<br>== true<br><br>red>> b: [1 2 3]<br>== [1 2 3]<br><br>red>> b <> [1 2 3]<br>== false<br><br>red>> 12 <> 12.0<br>== false<br><br>red>> "abc" <> "abc"<br>== false<br><br>red>> "abC" <> "ABC"<br>== false<br><b style="color: green">; Note uppercase considered equal to lowercase!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xeq"> =</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xeq">=</a> loosely compares operands on its left and right side and<br>returns <a href="./index.html#true">true</a> if the operand on the left is loosely equal to the operand on the<br>right. Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any <a href="./index.html#datatypexex">datatype!</a>.<br><br>Loose comparison means that:<br>- the case of strings is ignored when comparing<br>- same numeric values for different datatypes are considered equal<br></pre>例子<pre>2 = 3<br>== false<br><br>2 = 2.0<br>== true<br><br>22-03-2000 = 14-04-2012<br>== false<br><br>"ABC" = "abc"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xeqxeq"> ==</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xeqxeq">==</a> strictly compares operands on its left and right side and<br>returns <a href="./index.html#true">true</a> if the operand on the left is strictly equal to the operand on the<br>right. Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any <a href="./index.html#datatypexex">datatype!</a>.<br><br>The comparison is "strict", which means that:<br> - numeric operands are not equal if they have a different datatype<br> - string operands are not equal if their case differs<br></pre>例子<pre>2 == 3<br>== false<br><br>2 == 2.0<br>== false<br><br>22-03-2000 == 14-04-2012<br>== false<br><br>"ABC" == "abc"<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xeqxqm"> =?</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xeqxqm">=?</a> returns <a href="./index.html#true">true</a> if two values have the same identity.<br><br>As regards <a href="./index.html#seriesxex">series!</a> (including <a href="./index.html#stringxex">string!</a>s) the references (pointers) to <br>the <a href="./index.html#seriesxex">series!</a> are compared.<br></pre>例子<pre>red>> a: 22<br>== 22<br><br>red>> b: 22<br>== 22<br><br>red>> a =? b<br>== true<br><br>red>> c: [1 2 3]<br>== [1 2 3]<br><br>red>> d: c<br>== [1 2 3]<br><br>red>> c =? d<br>== true<br><b style="color: green">; Pointers are compared - they indeed reference the same series</b><br><br>red>> c: [3 2 1]<br>== [3 2 1]<br><br>red>> d: [3 2 1]<br>== [3 2 1]<br><br>red>> c = d<br>== true<br><b style="color: green">; Values are compared - are equal</b><br><br>red>> c =? d<br>== false<br><b style="color: green">; Pointers are compared - not referencing the same series</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xgt"> ></span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xgt">></a> loosely compares operands on its left and right side<br>returns <a href="./index.html#true">true</a> if the operand on the left is greater than the operand on<br>the right. Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any datatype<br><br>Loose comparison means that:<br>- the case of strings is ignored when comparing<br>- same numeric values for different datatypes are considered equal<br></pre>例子<pre>例子<br><br>2 > 3<br>== false<br><br>2 > 2.0<br>== false<br><br>22-03-2000 > 14-04-2012<br>== false<br><br>"ABC" > "abc"<br>== false<br><br>"abc" > "ABC"<br>== false<br><br>"abc" = "ABC"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xgtxeq"> >=</span> type: op! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>中缀词<a href="./index.html#xgtxeq">>=</a> loosely compares operands on its left and right side and<br>returns <a href="./index.html#true">true</a> if the operand on the left is greater than or equal to the operand<br>on the right. Otherwise returns <a href="./index.html#false">false</a>.<br><br>Has 2 operands of any <a href="./index.html#datatypexex">datatype!</a>.<br><br>Loose comparison means that:<br> - the case of strings is ignored when comparing<br> - same numeric values for different datatypes are considered equal<br></pre>例子<pre>2 >= 3<br>== false<br><br>2 >= 2.0<br>== true<br><br>22-03-2000 >= 14-04-2012<br>== false<br><br>"ABC" >= "abc"<br>== true<br><br>"abc" >= "ABC"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xgtxgt"> >></span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#xgtxgt">>></a> shifts its first argument (an <a href="./index.html#integerxex">integer!</a>) to the right<br>by the number of bits in its second argument (also an <a href="./index.html#integerxex">integer!</a>).<br><br>The sign is taken into account.<br></pre>例子<pre>red>> to-hex 6<br>== #00000006<br><br>red>> to-hex 6 >> 1<br>== #00000003<br><br>red>> to-hex 6 >> 2<br>== #00000001<br><br>red>> to-hex 6 >> 3<br>== #00000000<br><br>red>> to-hex 6 >> 4<br>== #00000000<br><br>red>> to-hex -6<br>== #FFFFFFFA<br><br>red>> to-hex -6 >> 1<br>== #FFFFFFFD<br><br>red>> to-hex -6 >> 2<br>== #FFFFFFFE<br><br>red>> to-hex -6 >> 3<br>== #FFFFFFFF<br><br>red>> to-hex -6 >> 4<br>== #FFFFFFFF<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xgtxgtxgt"> >>></span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#xgtxgtxgt">>>></a> shifts its first argument (an <a href="./index.html#integerxex">integer!</a>) to the right<br>by the number of bits in its second argument (also an <a href="./index.html#integerxex">integer!</a>).<br><br>This is a shift which ignores the sign.<br></pre>例子<pre>red>> to-hex 6<br>== #00000006<br><br>red>> to-hex 6 >>> 1<br>== #00000003<br><br>red>> to-hex 6 >>> 2<br>== #00000001<br><br>red>> to-hex 6 >>> 3<br>== #00000000<br><br>red>> to-hex 6 >>> 4<br>== #00000000<br><br>red>> to-hex -6<br>== #FFFFFFFA<br><br>red>> to-hex -6 >>> 1<br>== #7FFFFFFD<br><br>red>> to-hex -6 >>> 2<br>== #3FFFFFFE<br><br>red>> to-hex -6 >>> 3<br>== #1FFFFFFF<br><br>red>> to-hex -6 >>> 4<br>== #0FFFFFFF<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xqm"> ?</span> type: unset! <pre>This word is a synonym for <a href="./index.html#help">help</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="xqmxqm"> ??</span> type: function! Categories: <a href="./index.html#cat-d02">文档</a>, <a href="./index.html#cat-f02">格式化</a>, <a href="./index.html#cat-h01">帮助 & 调试</a><br><pre>关键字 <a href="./index.html#xqmxqm">?</a> prints a Red <a href="./index.html#wordxex">word!</a> (given as its argument)<br>and the value it refers to, in a molded format. This means that<br>the output includes type information (e.g. [ ], " ").<br><br>It is very useful for debugging.<br><br>Warning: when used with a <a href="./index.html#functionxex">function!</a> name, it displays the <br> <a href="./index.html#functionxex">function!</a> specification, rather than evaluating <br> that <a href="./index.html#functionxex">function!</a>.<br></pre>例子<pre>red>> age: 35<br>== 35<br><br>red>> ?? age<br>age: 35<br>== 35<br><br>red>> older: 1 + ?? age<br>age: 35<br>== 36<br><br>red>> ?? 44<br>*** Script error: ?? does not allow integer for its value argument<br>*** Where: ??<br><br>red>> ?? sin 0.4<br>sin: routine ["Returns the trigonometric sine" angle [float!] <br> "Angle in radians"][natives/sine* no 1]<br>== 0.4<br><b style="color: green">; Effectively the 0.4 here is a stand-alone value; </b><br><b style="color: green">; ?? does not do anything with it!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="a-an"> a-an</span> type: unset! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="about"> about</span> type: unset! Categories: <a href="./index.html#cat-h01">帮助 & 调试</a><br><pre>Displays the version of Red currently in use<br><br>Has no parameters<br></pre>例子<pre>about<br><b style="color: blue">Red 0.5.4 - 1-Dec-2015/11:46:16+1:00</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="absolute"> absolute</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>The <a href="./index.html#absolute">absolute</a> word evaluates an expression or a value <br>and returns the absolute value if the datatype is appropriate.<br><br>Has 1 parameter, an expression or a value<br></pre>例子<pre>absolute 1 - 3<br>== 2<br><b style="color: green">; 1 - 3 == -2</b><br><b style="color: green">; Returns the absolute value of -2, which is 2</b><br><br>absolute -2 / 5<br>== 0.4<br><b style="color: green">; -2 / 5 == -0.4</b><br><b style="color: green">; Returns the absolute value of -0.4, which is 0.4</b><br><br>absolute 6 / 3<br>== 2<br><b style="color: green">; 6 / 3 == 2</b><br><b style="color: green">; Returns the absolute value of 2, which is 2</b><br><br>absolute -2x5<br>== 2x5<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="acos"> acos</span> type: routine! <pre>This word is a synonym for <a href="./index.html#arccosine">arccosine</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="actionxex"> action!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#actionxex">action!</a> encompassess a specific set of <a href="./index.html#nativexex">native!</a><br><a href="./index.html#function">function</a>s.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; List all <a href="./index.html#functions">functions</a>s that are an <a href="./index.html#action">action</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ? action!<br> absolute => Returns the non-negative value<br> add => Returns the sum of the two values<br> and~ => Returns the first value ANDed with the second<br> append => Inserts value(s) at series tail; returns series head<br> at => Returns a series at a given index<br> back => Returns a series at the previous index<br> change => Changes a value in a series and returns the series after <br> the change.<br> clear => Removes series values from current index to tail; returns <br> new tail<br> complement => Returns the opposite (complementing) value of the input `<br> value<br> copy => Returns a copy of a non-scalar value<br> divide => Returns the quotient of two values<br> even? => Returns true if the number is evenly divisible by 2<br> find => Returns the series where a value is found, or NONE<br> form => Returns a user-friendly string representation of a value<br> head => Returns a series at its first index<br> head? => Returns true if a series is at its first index<br> index? => Returns the current index of series relative to the head, <br> or of word in a context<br> insert => Inserts value(s) at series index; returns series past the <br> insertion<br> length? => Returns the number of values in the series, from the current <br> index to the tail<br> make => Returns a new value made from a spec for that value's type<br> modify => Change mode for target aggregate value<br> mold => Returns a source format string representation of a value<br> move => Moves one or more elements from one series to another <br> position or series<br> multiply => Returns the product of two values<br> negate => Returns the opposite (additive inverse) value<br> next => Returns a series at the next index<br> odd? => Returns true if the number has a remainder of 1 when divided <br> by 2<br> or~ => Returns the first value ORed with the second<br> pick => Returns the series value at a given index<br> poke => Replaces the series value at a given index, and returns <br> the new value<br> power => Returns a number raised to a given power (exponent)<br> put => Replaces the value following a key, and returns the new value<br> random => Returns a random value of the same datatype; or shuffles series<br> read => Read from a file, URL, or other port<br> reflect => Returns internal details about a value via reflection<br> remainder => Returns what is left over when one value is divided by another<br> remove => Returns the series at the same index after removing a value<br> reverse => Reverses the order of elements; returns at same position<br> round => Returns the nearest integer. Halves round up (away from zero) <br> by default<br> select => Find a value in a series and return the next value, or NONE<br> skip => Returns the series relative to the current index<br> sort => Sorts a series (modified); default sort order is ascending<br> subtract => Returns the difference between two values<br> swap => Swaps elements between two series or the same series<br> tail => Returns a series at the index after its last value<br> tail? => Returns true if a series is past its last value<br> take => Removes and returns one or more elements<br> to => Converts to a specified datatype<br> trim => Removes space from a string or NONE from a block or object<br> write => Writes to a file, URL, or other port<br> xor~ => Returns the first value exclusive ORed with the second<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Check if a word is an <a href="./index.html#actionxex">action!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> action? :take <b style="color: green">; Colon is mandatory to get to function definition</b><br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="actionxqm"> action?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#actionxqm">action?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#actionxex">action!</a><br>type, or <a href="./index.html#false">false</a> otherwise.<br></pre>例子<pre>red>> action? :take <b style="color: green">; Colon is mandatory to get to function definition</b><br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="add"> add</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#add">add</a> adds 2 values together.<br>This is equivalent to the infix operator <a href="./index.html#xpl">+</a>.<br><br>Has 2 operands, which can be expressions or values<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add some <a href="./index.html#numberxex">number!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>add -1 3<br>== 2<br><br>add 4 / 2 5<br>== 7<br><b style="color: green">; 4 / 2 == 2</b><br><b style="color: green">; 2 + 5 == 7</b><br><b style="color: green">; Returns 7</b><br><br>add 2.3 7.77 - 2<br>== 8.07<br><b style="color: green">; 7.77 - 2 == 5,77</b><br><b style="color: green">; 2.3 + 5.77 == 8.07</b><br><b style="color: green">; Returns 8.07</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add a <a href="./index.html#numberxex">number!</a> 到一个 <a href="./index.html#pairxex">pair!</a> and vv</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> add 2x4 5<br>== 7x9<br><br>red>> add 5 2x4<br>== 7x9<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="all"> all</span> type: native! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>关键字 <a href="./index.html#all">all</a> evaluates each expression in a block in turn <br>and either returns the last resulting value (if that value is <br>not falsey) or returns <a href="./index.html#none">none</a> if it encounters a falsey <br>resulting value.<br><br>Has 1 parameter, a block.<br><br>The resulting value of <a href="./index.html#all">all</a> can be used in the if or either words, where <a href="./index.html#all">all</a><br>functions like a short-circuit <a href="./index.html#and">and</a>.<br></pre>例子<pre>all [1 + 1 2 + 2 3 = 3 2 + 6]<br>== 8<br><b style="color: green">; 1 + 1 == 2 (not falsey, so evaluation continues)</b><br><b style="color: green">; 2 + 2 == 4 (not falsey, so evaluation continues)</b><br><b style="color: green">; 3 = 3 == true (not falsey, so evaluation continues)</b><br><b style="color: green">; 2 + 6 == 8</b><br><b style="color: green">; Returns the last resulting value (8) because no falsey values detected</b><br><br>all [1 + 1 3 = 4 2 + 2 "John"]<br>== none<br><b style="color: green">; 1 + 1 == 2 (which is not falsey, so evaluation continues)</b><br><b style="color: green">; 3 = 4 == false</b><br><b style="color: green">; Returns none immediately, because a falsey value (false) is detected</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="also"> also</span> type: function! Categories: <a href="./index.html#cat-e02">评估</a>, <a href="./index.html#cat-s03">特殊目的</a><br><pre>关键字 <a href="./index.html#also">also</a> first evaluates its first argument and then<br>also evaluates its second argument.<br></pre>例子<pre>red>> a: 4<br>== 4<br><br>red>> b: 5<br>== 5<br><br>red>> also c: a + b c: c * a<br>== 9 <b style="color: green">; Returns result of first expression</b><br><br>red>> c<br>== 36 <b style="color: green">; Contains result of last expression</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="alter"> alter</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#alter">alter</a> appends/removes a value to/from a <a href="./index.html#seriesxex">series!</a>.<br>The value can be of any type.<br><br>If the value does NOT exist in the <a href="./index.html#seriesxex">series!</a> it is appended, and <a href="./index.html#true">true</a> is returned.<br>The original <a href="./index.html#seriesxex">series!</a> is modified.<br><br>If the value does exist, it is removed, and <a href="./index.html#false">false</a> is returned.<br><br>Note that <a href="./index.html#find">find</a> can be used to search a value in a <a href="./index.html#seriesxex">series!</a>.<br><br>There are no refinements.<br></pre>例子<pre>red>> a: ["cat" "dog"]<br>== ["cat" "dog"]<br><br>red>> alter a "fish"<br>== true<br><br>red>> a<br>== ["cat" "dog" "fish"]<br><br>red>> alter a "fish"<br>== false<br><br>red>> a<br>== ["cat" "dog"]<br><br>red>> find a "dog"<br>== ["dog"]<br><br>red>> find a "fish"<br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="and"> and</span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a>, <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>中缀词<a href="./index.html#and">and</a> performs a logical "and" of two values.<br>The values are restricted to these types:<br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>It is the infix version of the <a href="./index.html#andxsn">and~</a> word.<br><br>In the case of <a href="./index.html#and">and</a>ing two <a href="./index.html#integerxex">integer!</a>s (or types closely related to <a href="./index.html#integerxex">integer!</a>s,<br>such as <a href="./index.html#charxex">char!</a>, <a href="./index.html#pairxex">pair!</a>), a bitwise (bit-by-bit) process is performed.<br><br>In general, types can be mixed, but <a href="./index.html#logicxex">logic!</a> types cannot be mixed with other types.<br><br>The type of the result is the same type as the first value for a bitwise <a href="./index.html#and">and</a>.<br>For a logic <a href="./index.html#and">and</a> <a href="./index.html#true">true</a> or <a href="./index.html#false">false</a> are returned.<br><br>There are no refinements.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; And some <a href="./index.html#numberxex">number!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> (3 > 2) and true<br>== true<br><br>red>> 8 and 16<br>== 0<br>red>> 16 and false<br>*** Script error: logic type is not allowed here<br>*** Where: and<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; And <a href="./index.html#pairxex">pair!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> my-pair: 3x4<br>== 3x4<br><br>red>> my-pair and 1<br>== 1x0<br><br>red>> 1 and my-pair<br>*** Script error: and does not allow pair for its value2 argument<br>*** Where: and<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; And <a href="./index.html#vectorxex">vector!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> v1: make vector! [1 2 3]<br>== make vector! [1 2 3]<br><br>red>> v2: make vector! [1 1 1]<br>== make vector! [1 1 1]<br><br>red>> v1 and v2<br>== make vector! [1 0 1]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="andxsn"> and~</span> type: action! Categories: <a href="./index.html#cat-b02">位操作</a>, <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>The <a href="./index.html#andxsn">and~</a> word performs a logical "and" of its 2 arguments.<br>The arguments are restricted to these types:<br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>It is the functional version of the infix <a href="./index.html#and">and</a> word.<br><br>In the case of <a href="./index.html#andxsn">and~</a>ing two <a href="./index.html#integerxex">integer!</a>s (or types closely related to <a href="./index.html#integerxex">integer!</a>s,<br>such as <a href="./index.html#charxex">char!</a>, <a href="./index.html#pairxex">pair!</a>), a bitwise (bit-by-bit) process is performed.<br><br>In general, types can be mixed, but <a href="./index.html#logicxex">logic!</a> types cannot be mixed with other types.<br><br>The type of the result is the same type as the first value for a bitwise <a href="./index.html#andxsn">and~</a>.<br>For a logic <a href="./index.html#andxsn">and~</a> <a href="./index.html#true">true</a> or <a href="./index.html#false">false</a> are returned.<br><br>There are no refinements.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using <a href="./index.html#numberxex">number!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> and~ (3 > 2 ) true<br>== true<br><br>red>> and~ 8 16<br>== 0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using bad parameter</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> and~ 16 false<br>*** Script error: logic type is not allowed here<br>*** Where: and~<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using <a href="./index.html#pairxex">pair!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> my-pair: 3x4<br>== 3x4<br><br>red>> and~ my-pair 1<br>== 1x0<br><br>red>> and~ 1 my-pair<br>*** Script error: and~ does not allow pair for its value2 argument<br>*** Where: and~<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using <a href="./index.html#vectorxex">vector!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> v1: make vector![1 2 3]<br>== make vector! [1 2 3]<br><br>red>> v2: make vector![1 1 1]<br>== make vector! [1 1 1]<br><br>red>> and~ v1 v2<br>== make vector! [1 0 1]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any"> any</span> type: native! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>关键字 <a href="./index.html#any">any</a> evaluates each expression in a <a href="./index.html#blockxex">block!</a> in turn and returns<br>the first resulting value that is not falsey. <br><br>If all resulting values are falsey it returns <a href="./index.html#none">none</a>.<br><br>Has 1 parameter, a <a href="./index.html#blockxex">block!</a><br><br>The resulting value of <a href="./index.html#any">any</a> can be used in the <a href="./index.html#if">if</a> or <a href="./index.html#either">either</a> words, <br>where <a href="./index.html#any">any</a> functions like a short-circuit <a href="./index.html#or">or</a>.<br></pre>例子<pre>any [none false 1 false]<br>== 1<br><b style="color: green">; none -> none (is falsey, so evaluation continues)</b><br><b style="color: green">; false -> false (is falsey, so evaluation continues)</b><br><b style="color: green">; 1 == 1</b><br><b style="color: green">; Returns 1 immediately because a non falsey value (1) is detected</b><br><br>any [2 = 3 4 = 5 2 + 2 = 4 5 - 3 = 1]<br>== true<br><b style="color: green">; 2 = 3 == false (is falsey, so evaluation continues)</b><br><b style="color: green">; 4 = 5 == false (is falsey, so evaluation continues)</b><br><b style="color: green">; 2 + 2 = 4 == true</b><br><b style="color: green">; Returns true immediately because a non falsey value (true) is detected</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-blockxqm"> any-block?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-blockxqm">any-block?</a> returns <a href="./index.html#true">true</a> if its argument is of type <a href="./index.html#blockxex">block!</a>.<br></pre>例子<pre>red>> any-block? "w"<br>== false<br><br>red>> any-block? []<br>== true<br><br>red>> any-block? {}<br>== false<br><br>red>> any-block? [x [y z] 1 2]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-functionxqm"> any-function?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-functionxqm">any-function?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#functionxex">function!</a>.<br><br>It has no refinements.<br></pre>例子<pre>red>> any-function? a<br>== false<br><br>red>> any-function? :find<br>== true<br><b style="color: green">; The colon (:) gets the definition, not the value of a function</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-listxex"> any-list!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>关键字 <a href="./index.html#any-listxex">any-list!</a> is a typeset! of value: [<a href="./index.html#blockxex">block!</a> <a href="./index.html#parenxex">paren!</a> <a href="./index.html#hashxex">hash!</a>].<br><br>We can test if any item is an any-list! with the <a href="./index.html#any-listxqm">any-list?</a> function<br></pre>例子<pre>red>> any-list!<br>== make typeset! [block! paren! hash!]<br><br>red>> a: [1 2 3]<br>== [1 2 3]<br><br>red>> any-list? a<br>== true<br><br>red>> any-list? 3<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-listxqm"> any-list?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-listxqm">any-list?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#any-listxex">any-list!</a> type, <br>otherwise <a href="./index.html#false">false</a>. <br><br>An <a href="./index.html#any-listxex">any-list!</a> is a <a href="./index.html#typesetxex">typeset!</a> of: <br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#parenxex">paren!</a> <a href="./index.html#hashxex">hash!</a><br><br>Its argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; try some types with any-list?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> any-list? "text"<br>false<br><br>red>> any-list? 127.33.63<br>== false<br><br>red>> any-list? [22 33]<br>== true<br><br>red>> any-list? (2 3)<br>== false<br><br>red>> any-list? (2 3) <b style="color: green">; invalid - Red tries to evaluate the argument</b><br>== false<br><br>red>> first [(2 3)] <b style="color: green">; valid - [ ] prevents evaluation</b><br>== (2 3)<br><br>red>> any-list? first [(2 3)] <b style="color: green">; now it works!</b><br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-objectxex"> any-object!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="any-objectxqm"> any-object?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-objectxqm">any-object?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#objectxex">object!</a>.<br><br>It has no refinements.<br></pre>例子<pre>red>> my-obj: make object! [ x: 10 y: 10 ]<br>== make object! [<br> x: 10<br> y: 10<br>]<br><br>red>> any-object? my-obj<br>== true<br><br>red>> a: 22<br><br>red>> any-object? a<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-pathxex"> any-path!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="any-pathxqm"> any-path?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-pathxqm">any-path?</a> returns <a href="./index.html#true">true</a> if its argument is a valid <a href="./index.html#pathxex">path!</a> variant.<br>Otherwise <a href="./index.html#false">false</a>.<br><br>In Red, there are several types of <a href="./index.html#pathxex">path!</a> like:<br> <a href="./index.html#pathxex">path!</a> <a href="./index.html#lit-pathxex">lit-path!</a> <a href="./index.html#set-pathxex">set-path!</a> <a href="./index.html#get-pathxex">get-path!</a><br><br>For more details on the ways of interpreting a word (involving ' and :), <br>the reader should look at the <a href="./index.html#lit-wordxex">lit-word!</a>, <a href="./index.html#get-wordxex">get-word!</a> and <a href="./index.html#set-wordxex">set-word!</a> docs.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Standard paths. Note: we use a [block] to prevent evaluation</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> any-path? first [a/b/c]<br>== true<br><br>red>> path? first [a/b/c]<br>== true<br><br>red>> type? first [a/b/c]<br>== path!<br><br>red>> any-path? first [a / b] <b style="color: green">; Surprise - it is a division!</b><br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Set paths.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> any-path? first[a/b:]<br>== true<br><br>red>> set-path? first[a/b:]<br>== true<br><br>red>> type? first[a/b:]<br>== set-path!<br><br>red>> type? first[a:/b/c] <b style="color: green">; Surprise - because of colon in 2nd position!</b><br>== url!<br><br>red>> any-path? first [a:/b/c]<br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Get paths.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> any-path? first [:a/b/c]<br>== true<br><br>red>> get-path? first [:a/b/c]<br>== true<br><br>red>> type? first [:a/b/c]<br>== get-path!<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Lit paths.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> any-path? first ['a/b/c]<br>== true<br><br>red>> lit-path? first ['a/b/c]<br>== true<br> <br>red>> type? first ['a/b/c]<br>== lit-path!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-stringxex"> any-string!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="any-stringxqm"> any-string?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-stringxqm">any-string?</a> returns <a href="./index.html#true">true</a> if its argument is any type of <a href="./index.html#stringxex">string!</a>,<br>including the types <a href="./index.html#stringxex">string!</a>, <a href="./index.html#filexex">file!</a> and <a href="./index.html#urlxex">url!</a>.<br><br>It has no refinements.<br></pre>例子<pre>red>> any-string? http://www.aaa.com<br>== true<br><br>red>> any-string? "fred"<br>== true<br><br>red>> any-string? 123<br>== false<br><br>red>> any-string? %notes/data.txt<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="any-word"> any-word</span> type: unset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="any-wordxqm"> any-word?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#any-wordxqm">any-word?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#wordxex">word!</a>.<br><br>It has no refinements.<br></pre>例子<pre>red>> any-word? 123<br>== false<br><b style="color: green">; 123 is a number, not a symbol</b><br><br>red>> any-word? find<br>*** Script error: find is missing its series argument<br>*** Where: find<br><b style="color: green">; Red tries to invoke the function find but fails on missing arguments</b><br><br>red>> any-word? 'find<br>== true<br><b style="color: green">; Red takes quoted symbols literally</b><br><br>red>> any-word? :find<br>== false<br><b style="color: green">; A function definition is not a word</b><br><br>red>> a: 'find<br>== find<br><br>red>> any-word? a<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="append"> append</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#append">append</a> inserts value(s) at the end of a <a href="./index.html#seriesxex">series!</a> <br>and returns the head of the series. The original series is changed.<br><br>Arguments:<br> 1. the series to be extended can be any series a <a href="./index.html#bitmapxex">bitmap!</a> or a <a href="./index.html#mapxex">map!</a><br> 2. the value to be appended can be <a href="./index.html#any-typexex">any-type!</a><br><br>Refinements<br> /part - limit the number of values inserted. (a <a href="./index.html#numberxex">number!</a> or a series index)<br> /only - insert block types as single values (overrides /part).<br> /dup - duplicate the inserted values. Provide a <a href="./index.html#numberxex">number!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Append to a <a href="./index.html#blockxex">block!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-block: [1 2 3 "four" 5]<br>== [1 2 3 "four" 5]<br><br>red>> append a-block 6<br>== [1 2 3 "four" 5 6]<br><br>red>> append a-block [7 8 "nine" [10 11]]<br>== [1 2 3 "four" 5 6 7 8 "nine" [10 11]]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Append to a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-string: "ABCD"<br>== "ABCD"<br><br>red>> append a-string "123"<br>== "ABCD123"<br><br>red>> append a-string [6 5 4]<br>== "ABCD123654" <b style="color: green">; see what happens here?</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /part refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series-1: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6]<br><br>red>> series-2: [100 200 300 400 500]<br>== [100 200 300 400 500]<br><br>red>> append/part series-1 series-2 3<br>== [1 2 3 4 5 6 100 200 300] <b style="color: green">; only 3 items appended</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /only refinement </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series-1: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6]<br><br>red>> series-2: [100 200 300 400 500]<br>== [100 200 300 400 500]<br><br>red>> append/only series-1 series-2<br>== [1 2 3 4 5 6 [100 200 300 400 500]] <b style="color: green">; appended as a comnplete block</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /dup refinement - note duplicated values at end</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series-1: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6]<br><br>red>> series-2: [100 200]<br>== [100 200]<br><br>red>> append/dup series-1 series-2 3<br>== [1 2 3 4 5 6 100 200 100 200 100 200]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="arccosine"> arccosine</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#arccosine">arccosine</a> returns the trigonometric arccosine (in degrees by default).<br><br>Has 1 parameter, a <a href="./index.html#numberxex">number!</a>.<br><br>Refinements:<br>/radians : returns the angle in radians;<br> without refinement returns the angle in degrees.<br><br>The resulting numeric angle value of arccosine can be used in an expression.<br></pre>例子<pre>arccosine 0.5<br>== 60.0<br><br>arccosine/radians 1<br>== 0.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="arcsine"> arcsine</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#arcsine">arcsine</a> returns the trigonometric arcsine (in degrees by default).<br><br>Has 1 parameter, a <a href="./index.html#numberxex">number!</a>.<br><br>Refinements:<br>/radians : returns the angle in radians;<br> without refinement returns the angle in degrees.<br></pre>例子<pre>arcsine 0.5<br>== 30.0<br><br>arcsine/radians 0<br>== 0.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="arctangent"> arctangent</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#arctangent">arctangent</a> returns the trigonometric arctangent (in degrees by default).<br><br>Has 1 parameter, a <a href="./index.html#numberxex">number!</a>.<br><br>Refinements:<br>/radians : returns the angle in radians;<br> without refinement returns the angle in degrees.<br></pre>例子<pre>arctangent 0<br>== 0.0<br><br>arctangent/radians 0<br>== 0.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="arctangent2"> arctangent2</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#arctangent2">arctangent2</a> returns the angle of the point (y x) in radians, <br>when measured counter-clockwise from a circle's x axis, where 0x0 represents <br>the center of the circle. <br><br>Note that the parameter order is y, x. <br><br>The return value is between -pi and +pi. <br><br>Has 2 atrguments:<br> 1. y coordinate of <a href="./index.html#numberxex">number!</a> type<br> 2. x coordinate of <a href="./index.html#numberxex">number!</a> type<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show usage</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> arctangent2 0.001 2<br>0.0004999999583333396<br><br>red>> arctangent2 3 3<br>0.7853981633974483<br><br>red>> arctangent2 3 2<br>0.9827937232473291<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="as-color"> as-color</span> type: routine! Categories: <a href="./index.html#cat-c01">生成类型</a>, <a href="./index.html#cat-c07">转换</a>, <a href="./index.html#cat-c08">颜色</a><br><pre>关键字 <a href="./index.html#as-color">as-color</a> generates a <a href="./index.html#tuplexex">tuple!</a> with R, G and B values<br>from its 3 <a href="./index.html#integerxex">integer!</a> arguments.<br></pre>例子<pre>red>> as-color 255 0 0<br>== 255.0.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Predefined colors (e.g. <a href="./index.html#0red">red</a> <a href="./index.html#0green">green</a> etc.) are available also</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> red<br>== 255.0.0<br><br>red>> green<br>== 0.255.0<br><br>red>> yellow<br>== 255.255.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="as-ipv4"> as-ipv4</span> type: routine! Categories: <a href="./index.html#cat-c01">生成类型</a>, <a href="./index.html#cat-c07">转换</a><br><pre>关键字 <a href="./index.html#as-ipv4">as-ipv4</a> returns an IP version 4 address created from<br>its 4 <a href="./index.html#integerxex">integer!</a> arguments.<br><br>If an argument is not within the range 0 .. 255, Red tries to<br>"guess" an appropriate value using the modulo of its (absolute) value.<br></pre>例子<pre>red>> as-ipv4 1 3 12 253<br>== 1.3.12.253<br><br>red>> as-ipv4 1 3 12 0<br>== 1.3.12.0<br><br>red>> as-ipv4 1 3 12 255<br>== 1.3.12.255<br><br>red>> as-ipv4 1 3 12 256<br>== 1.3.12.0<br><br>red>> as-ipv4 1 3 12 257<br>== 1.3.12.1<br><br>red>> as-ipv4 1 3 12 258<br>== 1.3.12.2<br><br>red>> as-ipv4 0 3 12 255<br>== 0.3.12.255<br><br>red>> as-ipv4 -1 3 12 255<br>== 255.255.255.255<br><br>red>> as-ipv4 -2 3 12 255<br>== 254.255.255.255<br><br>red>> as-ipv4 -3 3 12 255<br>== 253.255.255.255<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="as-pair"> as-pair</span> type: native! Categories: <a href="./index.html#cat-c01">生成类型</a>, <a href="./index.html#cat-c07">转换</a><br><pre>关键字 <a href="./index.html#as-pair">as-pair</a> combines 2 <a href="./index.html#integerxex">integer!</a> or <a href="./index.html#floatxex">float!</a> values into a <a href="./index.html#pairxex">pair!</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Demonstrate mixed integers and floats, also truncation</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> as-pair 22 33<br>22x33<br><br>red>> as-pair 22 33.9<br>22x33<br><br>red>> as-pair 44.3 44.99<br>44x44<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="as-rgba"> as-rgba</span> type: routine! Categories: <a href="./index.html#cat-c01">生成类型</a>, <a href="./index.html#cat-c07">转换</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="asin"> asin</span> type: routine! <pre>This word is a synonym for <a href="./index.html#arcsine">arcsine</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="ask"> ask</span> type: unset! Categories: <a href="./index.html#cat-i01">输入</a><br><pre>Displays a prompt and gets the value that the user types at STDIN.<br><br>Has 1 parameter, a <a href="./index.html#stringxex">string!</a><br><br>The resulting string value of <a href="./index.html#ask">ask</a> can be used in an expression<br></pre>例子<pre>answer: ask "What is your name?"<br><b style="color: blue">What is your name?Carl</b><br>== "Carl"<br><br>answer<br>== "Carl"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="at"> at</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>The <a href="./index.html#at">at</a> word returns a <a href="./index.html#seriesxex">series!</a> at a given integer index.<br><br>Note that it does not extract one item. Rather, it returns a reference (pointer)<br>into the original <a href="./index.html#seriesxex">series!</a>.<br><br>The original <a href="./index.html#seriesxex">series!</a> is unchanged.<br><br>Note that <a href="./index.html#seriesxex">series!</a> (which includes <a href="./index.html#stringxex">string!</a>s) are indexed from 1.<br><br>If the index is off the 'left-hand side' of the <a href="./index.html#seriesxex">series!</a>, the whole <a href="./index.html#seriesxex">series!</a> <br>is returned.<br><br>If the <a href="./index.html#seriesxex">series!</a> is beyond the right-hand side, an empty <a href="./index.html#seriesxex">series!</a> is returned.<br><br>There are no refinements.<br></pre>例子<pre>red>> at [1 2 3 4 5] 3<br>== [3 4 5]<br><br>red>> at "abcde" 3<br>== "cde"<br><br>red>> at "abcd" 6<br>== ""<br><br>red>> at [1 2 3 4] -2<br>== [1 2 3 4]<br><br>red>> at [1 2 3 4] 0<br>== [1 2 3 4]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="atan"> atan</span> type: routine! <pre>This word is a synonym for <a href="./index.html#arctangent">arctangent</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="atan2"> atan2</span> type: native! <pre>This word is a synonym for <a href="./index.html#arctangent2">arctangent2</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="attempt"> attempt</span> type: function! Categories: <a href="./index.html#cat-e01">错误</a><br><pre>关键字 <a href="./index.html#attempt">attempt</a> tries to evaluate a <a href="./index.html#blockxex">block!</a> <br>and returns the result or <a href="./index.html#none">none</a> if an error occurs.<br><br>The effect of <a href="./index.html#attempt">attempt</a> is similar to that of error? try[block]. <br>If you need more details about specific errors, look at <a href="./index.html#try">try</a>, <br><a href="./index.html#cause-error">cause-error</a> <a href="./index.html#errorxqm">error?</a>, and the <a href="./index.html#errorxex">error!</a> type.<br><br></pre>例子<pre>red>> s: "abcd"<br>== "abcd"<br>red>> calc: 3 * s<br>*** Script error: * does not allow string for its value2 argument<br>*** 位置:*<br><br>red>> calc: attempt [3 * s]<br>== none<br>red>> calc<br>== none<br><br>red>> calc: attempt [3 * 2.2]<br>== 6.6<br>red>> calc<br>== 6.6<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="back"> back</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#back">back</a> moves the index of a <a href="./index.html#seriesxex">series!</a> 1 position towards<br>the <a href="./index.html#head">head</a> (= the start) of the <a href="./index.html#seriesxex">series!</a>.<br><br>When a <a href="./index.html#seriesxex">series!</a> index is already at <a href="./index.html#head">head</a> position, <a href="./index.html#back">back</a> won't<br>change the index; it stays at <a href="./index.html#head">head</a>.<br><br>The opposite of <a href="./index.html#back">back</a> is <a href="./index.html#next">next</a>.<br></pre>例子<pre>red>> ser: [1 2 3]<br>== [1 2 3]<br><br>red>> head? ser<br>== true<br><br>red>> index? ser<br>== 1<br><br>red>> back ser<br>== [1 2 3]<br><br>red>> ser: back ser<br>== [1 2 3]<br><br>red>> head? ser<br>== true<br><br>red>> index? ser<br>== 1<br><br>red>> ser: tail ser<br>== []<br><br>red>> index? ser<br>== 4<br><br>red>> ser: back ser<br>== [3]<br><br>red>> index? ser<br>== 3<br><br>red>> ser: back ser<br>== [2 3]<br><br>red>> index? ser<br>== 2<br><br>red>> ser: back ser<br>== [1 2 3]<br><br>red>> index? ser<br>== 1<br><br>red>> head? ser<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="binaryxex"> binary!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The binary! <a href="./index.html#datatypexex">datatype!</a> is a <a href="./index.html#seriesxex">series!</a>. Each element is a 0-255 <br>integer value. Literal binary values can be expressed with bases <br>2, 16, 64. Base 16 is the default.<br><br>Because of the byte-based representation, we must supply sufficient digits <br>to produce 8-bit units. Thus for base 16, we must provide 2, 4, 6 etc <br>digits, and for base 64, we must supply 4, 8, 12 etc digits. (4 base-64 <br>digits provide 24 bits, which splits into 3 bytes exactly).<br><br>The arithmetic functions do not allow binary! arguments.<br><br>Literals can be written with white space for readability, and upper or <br>lower-case letters can be used.<br><br>Readers of Rebol documentation should note that Red is closer to Rebol3 in <br>this area. There are major differences from Rebol2.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some literals</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;base 16 - hex<br>red>> #{0f}<br>== #{0F}<br><br>;base 2, with spaces<br>red>> #2{11110000 1111 0000}<br>== "11110000 1111 0000"<br>;base 64<br>red>> #64{ffff"}<br>== {ffff"}<br>;incorrect number of digits here<br>red>> #{fff}<br>*** Syntax Error: invalid binary! at "#{fff}"<br>*** Where: do<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use to binary!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;convert a string<br>red>> to binary! "1111ffff"<br>== #{3131313166666666}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use pick to get an integer element (FF)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: #{00<br> ff<br> 22<br>}<br>== #{00FF22}<br><br>red>> pick b 2<br>== 255<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="binaryxqm"> binary?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#binaryxqm">binary?</a> returns <a href="./index.html#true">true</a> if its argument is of <a href="./index.html#binaryxex">binary!</a> type.<br>A literal binary <a href="./index.html#seriesxex">series!</a> is surrounded by #{...}<br></pre>例子<pre>red>> binary? #{22}<br>== true<br><br>red>> binary? #{ 22 FF AA }<br>== true<br><br>red>> binary? 16<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="bind"> bind</span> type: native! Categories: <a href="./index.html#cat-o01">对象</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="bitsetxex"> bitset!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#bitsetxex">bitset!</a> datatype provides an array of bits that is used to store <br>boolean values. It is often used with <a href="./index.html#Parse">解析</a>, letting us represent <br>arbitrary sets of characters across the whole Unicode range, that can be <br>matched against an input character in a single operation.<br><br>In order to create a bitset, you need to provide one or several characters <br>as a base specification. They can be provided in different forms: codepoint <br><a href="./index.html#integerxex">integer!</a> values, <a href="./index.html#charxex">char!</a> values, <a href="./index.html#stringxex">string!</a> values, a range, or a <br>group of previous elements.<br><br>The bitset! indexing starts at zero. It is not a series! type.<br><br>Bitsets expand at the right as needed, to provide enough storage for additions.<br><br>A <a href="./index.html#charsetxex">charset!</a> shortcut function is provided for convenience, and is shown <br>below.<br><br>We create a new bitset! with make, and its argument must be one of: <br><br> <a href="./index.html#charxex">char!</a>, <a href="./index.html#integerxex">integer!</a>, <a href="./index.html#stringxex">string!</a> or <a href="./index.html#blockxex">block!</a><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create some bitsets</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; an empty bitset with places at least for 16 bits<br>;note the 4 hex digits displayed<br>red>> b-demo: make bitset! 16<br>== make bitset! #{0000}<br><br>; a bitset - space for at least 17 bits. Size is rounded to upper byte bound.<br>red>> b-demo2: make bitset! 17<br>== make bitset! #{000000}<br><br>; create a bitset with bit 65 set <br>red>> b-demo: make bitset! #"A" (16 x 0000 bits, then a 0100)<br>== make bitset! #{000000000000000040}<br><br>; create a bitset with bits 104 and 105 set<br>red>> a-set: make bitset! "hi"<br>== make bitset! #{00000000000000000000000000C0}<br><br>; create and set bits using different values, representations<br>red>> make bitset! [120 "hello" #"A"]<br>== make bitset! #{00000000000000004000000004890080}<br><br>; create a bitset using ranges of values<br>red>> bits-09-az: make bitset! [#"0" - #"9" #"a" - #"z"]<br>== make bitset! #{000000000000FFC0000000007FFFFFE0}<br>; Ranges are defined using two values (char! or integer! allowed)<br>; we them separate by a dash word.<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A shortcut charset function is also provided for practical usage,</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; so you can write:<br>red>> hex-set: charset "ABCDEF"<br>== make bitset! #{00000000000000007E}<br><br>red>> set-demo: charset [120 "hello" #"A"]<br>== make bitset! #{00000000000000004000000004890080}<br><br>red>> hyphen-demo: charset [120 "hello" #"A"]<br>== make bitset! #{00000000000000004000000004890080}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Auto-sizing. We start with "A", and add a "Z" at the right</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b-set: make bitset! "A"<br>== make bitset! #{000000000000000040}<br>red>> append b-set "Z"<br>== make bitset! #{000000000000000040000020}<br><br>; now we append a "-". Note that it goes in its proper place,<br>; not at the rightmost end<br>red>> append b-set "-"<br>== make bitset! #{000000000004000040000020}<br>; note that append modifies the original bitset<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reading and writing single bits. The path notation can be used</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; make a bitset<br>red>> a-set: make bitset! "ABCDEFG"<br>== make bitset! #{00000000000000007F}<br><br>;do some work on the "A" entry<br>red>> position: to integer! #"A"<br>== 65<br><br>;look for "A" - true, it is there? Yes.<br>red>> a-set/:position<br>== true<br><br>;remove it<br>red>> a-set/:position: false<br>== false<br>; look at the set, to prove it<br>red>> a-set<br>== make bitset! #{00000000000000003F}<br><br>;remove it (no difference, it was not there anyway)<br>red>> remove/part a-set position<br>== make bitset! #{00000000000000003F}<br><br>; now remove "B", leaving us with CDEFG - 5 bits, in the 1F below<br>red>> remove/part a-set #"B"<br>== make bitset! #{00000000000000001F}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The set functions can also be used:</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; union, difference, unique, intersect<br><br>; make 2 bitsets to work with<br>red>> chars: make bitset! "ABCDEFGH"<br>== make bitset! #{00000000000000007F80}<br><br>red>> more-chars: make bitset! "123ABCDEFGHxyz"<br>== make bitset! #{00000000000070007F800000000000E0}<br><br>; find the difference between them - note that 7F8 is missing in result<br>red>> difference chars more-chars<br>== make bitset! #{000000000000700000000000000000E0}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The complement function inverts every bit</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-set: make bitset! "ABCD"<br>== make bitset! #{000000000000000078}<br><br>red>> opposite: complement a-set<br>== make bitset! [not #{000000000000000078}]<br><br>; The original set is unaltered<br>red>> a-set<br>== make bitset! #{000000000000000078}<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="bitsetxqm"> bitset?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#bitsetxqm">bitset?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#bitsetxex">bitset!</a> type.<br></pre>例子<pre>red>> b: make bitset! [1 3 5]<br>== make bitset! #{54}<br><br>red>> n: [2 3 6]<br>== [2 3 6]<br><br>red>> bitset? b<br>== true<br><br>red>> bitset? n<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="blockxex"> block!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#blockxex">block!</a> represents a <a href="./index.html#seriesxex">series!</a> type.<br><br>They are enclosed in square brackets [ ] and can run over many lines.<br><br>The adagium <b style="color: blue">code = data</b> fits very well for a <a href="./index.html#blockxex">block!</a>.<br>A <a href="./index.html#blockxex">block!</a> is just a block of data, but blocks can also be used<br>as part of the code.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a <a href="./index.html#blockxex">block!</a>以及一个<a href="./index.html#stringxex">string!</a>, an <a href="./index.html#integerxex">integer!</a> and a <a href="./index.html#floatxex">float!</a> in it.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ["Mike" 55 1.95]<br>== ["Mike" 55 1.95]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a <a href="./index.html#blockxex">block!</a> in program code.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> if 3 > 2 [print "bigger"]<br>== bigger <br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Code = data</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a: 22<br>== 22<br><br>red>> my-block: [4 + a]<br>== [4 + a] <b style="color: green">; Just a data <a href="./index.html#blockxex">block!</a></b><br><br>red>> do my-block<br>== 26 <b style="color: green">; Happens to contain valid code!</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Beware of <a href="./index.html#unsetxex">unset!</a> values in a <a href="./index.html#blockxex">block!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> my-data: [name "Li" age 42]<br>== [name "Li" age 42]<br><br>red>> print my-data<br>*** Script Error: name has no value<br>*** Where: print<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="blockxqm"> block?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#blockxqm">block?</a> returns <a href="./index.html#true">true</a> if its parameter is a <br>valid <a href="./index.html#blockxex">block!</a> or <a href="./index.html#false">false</a> otherwise.<br><br>Has 1 parameter.<br></pre>例子<pre>block? "test"<br>== false<br><br>block? [test 1 2 3]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="body-of"> body-of</span> type: function! Categories: <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#body-of">body-of</a> shows the body of a <a href="./index.html#functionxex">function!</a> type.<br><br>This word is tightly related with the <a href="./index.html#source">source</a> word.<br></pre>例子<pre>red>> x: function [a b] [ a + b ]<br>== func [a b][a + b]<br><br>red>> source x<br>x: func [a b][a + b]<br><br>red>> body-of :x<br>== [a + b]<br><br>red>> source list-dir<br>list-dir: func [<br> {Displays a list of files and directories from given folder or current one} <br> dir [any-type!] "Folder to list" <br> /col "Forces the display in a given number of columns" <br> n [integer!] "Number of columns" <br> /local list max-sz name<br>][<br> unless value? 'dir [dir: %.] <br> unless find [file! word! path!] type?/word :dir [<br> cause-error 'script 'expect-arg ['list-dir type? :dir 'dir]<br> ] <br> list: read normalize-dir dir <br> max-sz: either n [system/console/limit / n - n] [<br> n: max 1 system/console/limit / 22 <br> 22 - n<br> ] <br> while [not tail? list] [<br> loop n [<br> if max-sz <= length? name: list/1 [<br> name: append copy/part name max-sz - 4 "..."<br> ] <br> prin tab <br> prin pad form name max-sz <br> prin " " <br> if tail? list: next list [exit]<br> ] <br> prin lf<br> ]<br>]<br><br>red>> print mold body-of :list-dir<br><b style="color: blue">[</b><br><b style="color: blue"> unless value? 'dir [dir: %.]</b><br><b style="color: blue"> unless find [file! word! path!] type?/word :dir [</b><br><b style="color: blue"> cause-error 'script 'expect-arg ['list-dir type? :dir 'dir]</b><br><b style="color: blue"> ]</b><br><b style="color: blue"> list: read normalize-dir dir</b><br><b style="color: blue"> max-sz: either n [system/console/limit / n - n] [</b><br><b style="color: blue"> n: max 1 system/console/limit / 22</b><br><b style="color: blue"> 22 - n</b><br><b style="color: blue"> ]</b><br><b style="color: blue"> while [not tail? list] [</b><br><b style="color: blue"> loop n [</b><br><b style="color: blue"> if max-sz <= length? name: list/1 [</b><br><b style="color: blue"> name: append copy/part name max-sz - 4 "..."</b><br><b style="color: blue"> ]</b><br><b style="color: blue"> prin tab</b><br><b style="color: blue"> prin pad form name max-sz</b><br><b style="color: blue"> prin " "</b><br><b style="color: blue"> if tail? list: next list [exit]</b><br><b style="color: blue"> ]</b><br><b style="color: blue"> prin lf</b><br><b style="color: blue"> ]</b><br><b style="color: blue">]</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="break"> break</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#break">break</a> breaks out of a loop.<br><br>Refinements:<br> /return : forces the loop function to <a href="./index.html#return">return</a> the value following.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Normal example</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>foreach number [1 2 4 8 16] [<br> if number > 8 [break]<br> print number<br>]<br>print "loop 1 teminated"<br><b style="color: blue">1</b><br><b style="color: blue">2</b><br><b style="color: blue">4</b><br><b style="color: blue">8</b><br><b style="color: blue">loop 1 teminated</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Contreived example</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>print foreach number [1 2 4 8 16] [<br> if number > 8 [break/return -999]<br> print number<br> ]<br>print "loop 2 teminated"<br><b style="color: blue">1</b><br><b style="color: blue">2</b><br><b style="color: blue">4</b><br><b style="color: blue">8</b><br><b style="color: blue">-999</b><br><b style="color: blue">loop 2 teminated</b><br><b style="color: green">; The foreach loop returns the value -999,</b><br><b style="color: green">; which in turn is printed by "print"</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="browse"> browse</span> type: routine! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>关键字 <a href="./index.html#browse">browse</a> opens a web browser with the specified URL.<br><br>The single argument is a <a href="./index.html#urlxex">url!</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Open a web browser pointing to Google. Execution continues</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> browse http://www.google.com<br>red>> <b style="color: green">; execution continues here</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="call"> call</span> type: unset! Categories: <a href="./index.html#cat-s05">系统相关</a><br><pre><br>关键字 <a href="./index.html#call">call</a> executes a shell command to run another process. <br> <br>The argument is:<br><br> A command [<a href="./index.html#stringxex">string!</a> <a href="./index.html#filexex">file!</a>] - A shell command or an executable file. <br><br>Refinements<br> /wait - Runs command and waits for exit. <br> /show - Force the display of system's shell window (Windows only). <br> /console - Runs command with I/O redirected to console (CLI console only at present). <br> /shell - Forces command to be run from shell. <br> /input - we provide a [<a href="./index.html#stringxex">string!</a> <a href="./index.html#filexex">file!</a> <a href="./index.html#binaryxex">binary!</a>], which will be redirected to stdin.<br> /output - we provide a [<a href="./index.html#stringxex">string!</a> <a href="./index.html#filexex">file!</a> <a href="./index.html#binaryxex">binary!</a>] which will<br>receive the redirected stdout from the command. Note that the<br>output is appended.<br>If you don't want this, clear the destination(or delete the file, for example).<br><br> /error - as /output, but redirects stderr.<br>.aad <br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Please note:</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; These examples were run on Windows 7. Prints are included,<br>; to provide confirmation of a call starting and ending.<br>; File paths that do not begin with a / are relative paths.<br>; Enclose spaces in " ", or use hex codes<br>; ( '/' works on GNU/Linux, and Windows)<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Call a non-gui program in current directory. % precedes a file name. </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>print "The program only displays a message, and is not visible-on-screen"<br>call %hi-exe.exe<br>Print "Done 1"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Call notepad++ editor, with absolute path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>print "The notepad++ pops up, and this program continues"<br>call %"C:/Program Files/notepadPP/notepad++.exe"<br>print "Done 2"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Call notepad++ editor, with relative path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>call %"../Program Files/notepadPP/notepad++.exe"<br>print "Done 3"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Call notepad++, with a command-line argument for it.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>call %"C:/Program Files/notepadPP/notepad++.exe myData.txt" <br>print "Done 4"<br><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /wait refinement. Call notepad++, wait till user closes it.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>print "The notepad++ pops up, and this program continues"<br>call/wait %"C:/Program Files/notepadPP/notepad++.exe"<br>print "Done 5"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /output refinement - redirect output of hi-exe.exe to file hi-out.txt</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>call/output %hi-exe.exe %hi-out.txt<br>print "Done 6"<br><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /output - from a .bat file containing Dos commands (A dir command here)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>call/output %bat-demo.bat %dir-out.txt <br>print "Done 7"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /output - with the output from a Dos command going to a string</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>a-string: ""<br>call/output "dir *.txt" a-string <br>print ["Dir listing is: " a-string]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /show - run a command-file. Its window flashes up, then vanishes</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>call/show %bat-demo.bat <br>print "Done 8"<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="case"> case</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a><br><pre>关键字 <a href="./index.html#case">case</a> provides a multi-way branch structure. <br>The <a href="./index.html#blockxex">block!</a> following the first <a href="./index.html#true">true</a> condition is evaluated.<br><br>The result of a <a href="./index.html#case">case</a> is the value of the last expression evaluated.<br><br>Conditional expressions are supported, rather than the simpler form <br>in the <a href="./index.html#switch">switch</a> word.<br><br>Refinement:<br> /all : causes the blocks for every <a href="./index.html#true">true</a> condition to be evaluated.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; <a href="./index.html#case">case</a> without /all refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>n: 555<br>case [<br> n < 10 [print "small"]<br> n < 100 [print "medium"]<br> n < 1000 [print "large"]<br> true [print "none of these"] <br>]<br><b style="color: blue">large</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; <a href="./index.html#case">case</a> with /all refinement (1)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>n: 555<br>case/all [<br> n < 10 [print "small"]<br> n < 100 [print "medium"]<br> n < 1000 [print "large"]<br> true [print "none of these"] <br>]<br><b style="color: blue">large</b><br><b style="color: blue">none of these</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; <a href="./index.html#case">case</a> with /all refinement (2)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>n: 555<br>case/all [<br> n > 10 [print "small"]<br> n > 100 [print "medium"]<br> n > 1000 [print "large"]<br> true [print "none of these"] <br>]<br><b style="color: blue">small</b><br><b style="color: blue">medium</b><br><b style="color: blue">none of these</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="catch"> catch</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a>, <a href="./index.html#cat-e01">错误</a><br><pre>Catches a throw from a block and returns its value. Note that <a href="./index.html#catch">catch</a> <br>and throw are mainly intended for creating new control structures, and <br>are not the main exception-handling functions. For this, look at <a href="./index.html#attempt">attempt</a>, <br><a href="./index.html#try">try</a>, <a href="./index.html#cause-error">cause-error</a> <a href="./index.html#errorxqm">error?</a>, and <a href="./index.html#errorxex">error!</a>.<br><br>Arguments<br>The single argument must be a <a href="./index.html#block">block</a> to evaluate.<br><br>Refinements<br> /name - Catches a named throw. We supply a <a href="./index.html#word">word</a> or <a href="./index.html#block">block</a><br> of words, which are intended to match a named <a href="./index.html#throw">throw</a> or one of<br> several named throws.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; This complete example shows various catch/throw possibilities.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;It is rather artificial - we could get the same effect with<br>;more 'either' instructions.<br>;The example has a flavour of exception-handling, but in Red<br>;we should really use 'try', 'error?' etc for proper exception-handling.<br>;throw and catch are intended for building control-structures<br><br>;a function for the examples.<br>grade-a-mark: function [<br> "Convert a % mark to a letter grade, with an un-named throw"<br> mark [integer!]] [<br> print ""<br> print ["In grade-a-mark, with " mark]<br> if mark > 100 [throw "special"] ;value of the throw is a string<br> print "about to grade the mark (assume always A for now)"<br> "A"<br>]<br><br>;Example with no catch - commented out ------------------------<br><br>; the code: print grade-a-mark 102<br>;would cause execution to halt, with this error:<br>; *** Throw Error: no catch for throw: "special"<br><br>print ""<br>print "Examples with catch and throw (un-named)-----------------"<br><br>; catches our throw, but NOT arithmetic errors (e.g. zero-divide)<br>print catch [grade-a-mark 103] ; prints: too big<br><br>;now, take some action after catching, using returnedresult<br>if (catch [grade-a-mark 104]) = "special" [<br> print "caught a throw: special"<br>]<br><br>print ""<br>print "Examples with catch and throw using /name --------------"<br><br>;a similar function, with 2 named throws<br>grade-a-mark-named: function [<br> "Convert a % mark to a letter grade - version 2 - 2 named throws"<br> mark [integer!]] [<br> print ""<br> print ["In grade-a-mark-named, with " mark]<br> ;throws with a 'word<br> if mark > 100 [throw/name mark 'special-one] ;throw has a name as well as a value<br> if mark < 0 [throw/name mark 'too-small]<br> [print "grade-a-mark-named: about to grade the mark (assume always A for now)"<br> "A"<br> ]<br>]<br><br>print "Catching any throw, displaying returned value"<br>print catch [grade-a-mark-named 105]<br><br>print "Now catching named throws via 'word argument for refinement"<br>if (catch/name [grade-a-mark-named 106] 'special-one) [<br> print "caught a throw named 'special-one"<br>]<br><br>if (catch/name [grade-a-mark -3] 'too-small) [<br> print "caught a throw named 'too-small"<br>]<br><br>print ""<br>print "Now catching a selection of named throws"<br>;because the names are in a block, we don't need the '<br>if (catch/name [grade-a-mark-named -4] [special-one too-small]) [<br> print "caught either 'special-one or 'too-small"<br>]<br><br><br>OUTPUT FROM THE ABOVE:<br>---------------------<br><br>Examples with catch and throw using /name --------------<br>Catching any throw, displaying returned value<br><br>In grade-a-mark-named, with 105<br>105<br>Now catching named throws via 'word argument for refinement<br><br>In grade-a-mark-named, with 106<br>caught a throw named 'special-one<br><br>In grade-a-mark, with -3<br>about to grade the mark (assume always A for now)<br>caught a throw named 'too-small<br><br>Now catching a selection of named throws<br><br>In grade-a-mark-named, with -4<br>caught either 'special-one or 'too-small<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="cause-error"> cause-error</span> type: function! Categories: <a href="./index.html#cat-e01">错误</a><br><pre>Causes an immediate error, with the provided values. Note that this is <br>not a <a href="./index.html#throw">throw</a>, and cause-error does not co-operate with <a href="./index.html#throw">throw</a> and <br><a href="./index.html#catch">catch</a>. <br><br>For other error/exception-handling words, look at the related entries for <br><a href="./index.html#attempt">attempt</a>, <a href="./index.html#try">try</a>, <a href="./index.html#errorxqm">error?</a>, and the <a href="./index.html#errorxex">error!</a> type.<br><br>Arguments<br><br>Here we show how to view the pre-defined Red errors, which can be used as <br>arguments. The 3 arguments are:<br><br>Argument 1: err-type - a <a href="./index.html#wordxex">word!</a><br> This is a general category of error. A list of these can be obtained <br> by typing the following at the Red console: <br> words-of system/catalog/errors<br> <br>which currently displays:<br> [throw note syntax script math access user internal]<br><br>Argument 2: err-id - a <a href="./index.html#wordxex">word!</a><br> The specific error id words in a type can be obtained by typing e.g.:<br> ? system/catalog/errors/math<br>which displays:<br> `system/catalog/errors/math` is an object! of value:<br> code integer! 400<br> type string! Math Error<br> zero-divide string! attempt to divide by zero<br> overflow string! math or number overflow<br> positive string! positive number required<br><br><br>Argument 3: args - a <a href="./index.html#blockxex">block!</a><br> Some errors take no arguments, and we can supply an empty block. The <br> zero-divide word above is such an error. However, when we look in the <br> script type, we see around 70 error words, including, for example:<br><br> no-value block! [:arg1 "has no value"]<br><br> which takes 1 argument. We can supply any required arguments in a block.<br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Cause some errors. (Abstract examples, no purpose to the errors)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>do-work: function [ ] [<br> sum: 0 <br> ;note the empty block for the 3rd argument:<br> cause-error 'math 'zero-divide [] <br>]<br>print do-work<br><br>*** Math Error: attempt to divide by zero<br>*** Where: do<br><br><br>do-work: function [ ] [<br> sum: 0<br> ;note the 3rd argument - often a word, could be e.g. a string.<br> cause-error 'script 'no-value ['sum] <br>]<br>print do-work<br><br>*** Script Error: sum has no value<br>*** Where: do<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="cd"> cd</span> type: unset! <pre>This word is a synonym for <a href="./index.html#change-dir">change-dir</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="change"> change</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#change">change</a> changes a value in a <a href="./index.html#seriesxex">series!</a> and returns the series beyond<br>the change position. The original series is changed.<br><br>Arguments:<br> 1. <a href="./index.html#seriesxex">series!</a> positioned at the point to change.<br> 2. new value to insert - any type.<br><br><br>Refinements<br> /part - limits the amount to change to a given length (number) or position (index)<br> /only - changes a series as a series.<br> /dup - duplicates the change a specified number of times<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Changing a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdef"<br>== "abcdef"<br><br>red>> change s "NEW"<br>== "def"<br><br>red>> s<br>== "NEWdef"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Changing a <a href="./index.html#blockxex">block!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [22 33 44 55]<br>== [22 33 44 55]<br><br>red>> change b 11<br>== [33 44 55]<br><br>red>> b<br>== [11 33 44 55]<br><br>red>> b: next head b<br>== [33 44 55]<br><br>red>> change b 10<br>== [44 55]<br><br>red>> b<br>== [10 44 55]<br><br>red>> b: head b<br>== [11 10 44 55]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /part refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdef"<br>== "abcdef"<br><br>red>> change/part s "ABCD" 2<br>== "cdef" <b style="color: green">; the 2 limits the length of the part to be replaced</b><br><br>red>> s<br>== "ABCDcdef"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /only refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [11 22 33]<br>== [11 22 33]<br><br>red>> change/only s [1 2]<br>== [22 33]<br><br>red>> s<br>== [[1 2] 22 33]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The same example, but without /only</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [11 22 33]<br>== [11 22 33]<br><br>red>> change s [1 2]<br>== [33]<br><br>red>> s<br>== [1 2 33]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /dup refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdef"<br>== "abcdef"<br><br>red>> change/dup s "<>" 2<br>== "ef"<br><br>red>> s<br>== "<><>ef"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="change-dir"> change-dir</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#change-dir">change-dir</a> changes the current directory.<br><br>The argument can be one of <a href="./index.html#filexex">file!</a> <a href="./index.html#wordxex">word!</a> <a href="./index.html#pathxex">path!</a>.<br><br>The directory to change to can be:<br> - an absolute <a href="./index.html#pathxex">path!</a><br> - a relative <a href="./index.html#pathxex">path!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using an absolute path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> change-dir %/e/src<br>== %/e/src/<br><br>red>> dir<br> 8th/ go/ python/ red/ spiderbasic/ <br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a relative path </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> change-dir %go<br>== %/e/src/go/<br><br>red>> dir<br> bin32/ bin64/ pkg/ src/ <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="charxex"> char!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#charxex">char!</a> represents a <a href="./index.html#scalarxex">scalar!</a> type containing <br>a single <a href="./index.html#charxex">char!</a>.<br><br>A literal looks like:<br> #"A"<br>Only a single character is valid. So e.g. #"AZ" is invalid!<br><br>A <a href="./index.html#seriesxex">series!</a> of <a href="./index.html#charxex">char!</a> is a <a href="./index.html#stringxex">string!</a>.<br><br>Representation of the letter A as a:<br> <a href="./index.html#charxex">char!</a> -> #"A"<br> <a href="./index.html#stringxex">string!</a> -> "A"<br><br>The caret ^ is the escape character for special ASCII codes:<br> - a numeric value is interpreted as HEX<br> - null, line, tab, page, esc, back, delete<br>To use such a code, specify:<br> #"^(code)"<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> #"A"<br>== #"A"<br><br>red>> print #"A"<br><b style="color: blue">A</b><br> <br>red>> print #"^(41)" <b style="color: green">; Hex 41 is decimal 65 is ASCII A</b><br><b style="color: blue">A</b><br> <br>red>> first "dog" <b style="color: green">; A char! as element of a <a href="./index.html#stringxex">string!</a> <a href="./index.html#seriesxex">series!</a></b><br>== #"d"<br><br>red>> print #"^(line)" <b style="color: green">; Output a blank line</b><br><br> <br>red>> prin 3 prin #"^(tab)" print 6<br><b style="color: blue">3 6</b><br><br>red>> #"A" + 1<br>== #"B"<br><br>red>> #"B" > #"A"<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="charxqm"> char?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>The <a href="./index.html#charxqm">char?</a> word returns <a href="./index.html#true">true</a> if the value is a <a href="./index.html#charxex">char!</a> type. <br></pre>例子<pre>red>> char? 33<br>== false<br><b style="color: green">; 33 is a number and thus not a char!</b><br><br>red>> char? #"A"<br>== true<br><br>red>> char? "AB"<br>== false<br><b style="color: green">; "AB" is a string, which is a series type</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="charset"> charset</span> type: function! Categories: <a href="./index.html#cat-s02">集合</a><br><pre>关键字 <a href="./index.html#charset">charset</a> is a helper function for the <a href="./index.html#bitsetxex">bitset!</a> type. <br><br>In Red, the main use of bitsets is with character sets (possibly <br>across the whole Unicode range). <br><br>The charset function provides simplified creation with ranges.<br> <br>In cases when it is tedious to create massive bitsets (perhaps with huge <br>numbers of Unicode characters) we can create complemented sets, using <a href="./index.html#not">not</a>.<br><br>The single argument can be:<br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#stringxex">string!</a><br> We can also use the hyphen "-" to specify ranges.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create some bitsets with charset </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> vowels: charset ["AEIOU"]<br>== make bitset! #{0000000000000000444104}<br><br>red>> digits: charset ["0123456789"]<br>== make bitset! #{000000000000FFC0}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a range, with -</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> alpha: charset [#"A" - #"Z" #"a" - #"z"] <br>== make bitset! #{00000000000000007FFFFFE07FFFFFE0}<br>red>> <br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Mixed types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> set-demo: charset [120 "hello" #"A"]<br>== make bitset! #{00000000000000004000000004890080}<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Complementing -> all unicode characters except these 10</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> charset [not "0123456789"] <br>== make bitset! [not #{000000000000FFC0}]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="checksum"> checksum</span> type: native! Categories: <a href="./index.html#cat-n01">网络</a><br><pre>关键字 <a href="./index.html#checksum">checksum</a> computes a checksum, CRC, hash, or HMAC. <br><br>Arguments<br> 1. data = <a href="./index.html#binaryxex">binary!</a>, <a href="./index.html#stringxex">string!</a> or <a href="./index.html#filexex">file!</a><br> 2. the checksum method - a word:<br> MD5 SHA1 SHA256 SHA384 SHA512 CRC32 TCP hash.<br> <br>Refinements<br> /with - extra value for HMAC key or hash table size; <br> not compatible with TCP/CRC32 methods.<br> The value we supply can be:<br> <a href="./index.html#any-stringxex">any-string!</a> <a href="./index.html#binaryxex">binary!</a> <a href="./index.html#integerxex">integer!</a><br> string or binary for MD5/SHA* HMAC key<br> <a href="./index.html#integerxex">integer!</a> for hash table size.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Do a CRC and MD5 checksum</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> checksum "some text" 'CRC32<br>== 1337638330<br> <br>red>> checksum "some text" 'MD5<br>== #{552E21CD4CD9918678E3C1A0DF491BC3}<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="clean-path"> clean-path</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#clean-path">clean-path</a> cleans-up '.' and '..' in a <a href="./index.html#path">path</a> <br>and returns the cleaned path. <br><br>The argument can be:<br> <a href="./index.html#filexex">file!</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#stringxex">string!</a><br><br>Refinements<br> /only - do not prepend current directory.<br> /dir - add a trailing / if missing.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Remove some redundant parent (..) and current(.) uses.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> clean-path %/folder1/folder2/folder3/../../file.txt<br>== %/folder1/file.txt<br><br>red>> clean-path %/folder1/folder2/././file.txt<br>== %/folder1/folder2/file.txt<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /dir refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> clean-path/dir %/folder1/folder2<br>== %/folder1/folder2/<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /only refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> clean-path/only %folder1/file.txt<br>== %file.txt<br><br>red>> clean-path %folder1/file.txt <b style="color: green">; without /only</b><br>== %/C/red/folder1/file.txt<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Clean up a URL</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> clean-path http://www/./google.com<br>== %/www/google.com<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="clear"> clear</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#clear">clear</a> deletes the contents of a <a href="./index.html#series">series</a> starting from the current<br>index.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Clear a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdefghijklm"<br>== "abcdefghijklm"<br><br>red>> clear s<br>== ""<br><br>red>> s<br>== ""<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Clear part of a <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> n: [1 2 3 4 5 6 7]<br>== [1 2 3 4 5 6 7]<br><br>red>> clear skip n 3<br>== []<br><br>red>> n<br>== [1 2 3]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Clear from a found position</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "the quick brown fox jumps over the lazy dog"<br>== "the quick brown fox jumps over the lazy dog"<br><br>red>> clear find s "jumps"<br>== ""<br><br>red>> s<br>== "the quick brown fox "<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="clear-reactions"> clear-reactions</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="collect"> collect</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>Collect in a new block all the values passed to the 'keep' function from <br>the body block. We often use collect and keep in <a href="./index.html#parse">parse</a>.<br><br>Argument<br><br>A body <a href="./index.html#blockxex">block!</a> to evaluate.<br><br>Refinements<br><br> /into - Insert into a buffer instead (returns position after insert). <br> We supply a <a href="./index.html#seriesxex">series!</a>, which will be modified.<br><br></pre>例子<pre>.box<br>;create a block, with no keeps<br>red>> b: [4 3 * 3 (3 * 10) (5 * 100)]<br><br>;nothing to collect<br>red>> collect b<br>== []<br><br>;now use keep<br>red>> b: [keep 4 3 * 3 keep (3 * 10) (5 * 100)]<br><br>;note the 'kept' items<br>red>> collect b<br>== [4 30]<br><br>; try the /into refinement<br>; buf for /into<br>red>> buf: ["item 1"]<br><br>red>> b<br>== [keep 4 3 * 3 keep (3 * 10) (5 * 100)]<br>red>> collect/into b buf<br>== ["item 1" 4 30]<br><br>;note value of buf<br>red>> buf<br>== ["item 1" 4 30]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="comment"> comment</span> type: function! Categories: <a href="./index.html#cat-d02">文档</a><br><pre>关键字 <a href="./index.html#comment">comment</a> introduces a comment in a Red program.<br><br>It has the form:<br> comment {<br> ... multi-line comment ...<br> }<br>or:<br> comment " ... single-line comment ... "<br></pre>例子<pre>comment { <br> This is a multi-line comment,<br> consisting of more than one line.<br>}<br><br>comment "And this is a single-line comment!"<br> <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="complement"> complement</span> type: action! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#complement">complement</a> returns the complement of the argument.<br><br>Has one argument, of type: <br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a><br><br>For <a href="./index.html#logicxex">logic!</a>, it returns <a href="./index.html#true">true</a> or <a href="./index.html#false">false</a>.<br><br>For values with an accessible bit representation, it returns the <br>"ones complement".<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; With <a href="./index.html#logicxex">logic!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> complement 3 > 2<br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; With <a href="./index.html#integerxex">integer!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> complement 2<br>== -3<br><br>red>> complement -1<br>== 0<br><br>red>> complement 63<br>== -64<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; With <a href="./index.html#bitsetxex">bitset!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> b: make bitset![0 1]<br>== make bitset! #{C0}<br><br>red>> complement b<br>== make bitset! [not #{C0}]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="complementxqm"> complement?</span> type: native! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#complementxqm">complement?</a> returns <a href="./index.html#true">true</a> if the bitset is <br>complemented (that is: inverted with <a href="./index.html#not">not</a>).<br></pre>例子<pre>red>> vowels: charset ["AEIOU"]<br>== make bitset! #{0000000000000000444104}<br><br>red>> complement? vowels<br>== false<br><br>red>> non-digits: charset [ not "0123456789"]<br>== make bitset! [not #{000000000000FFC0}]<br><br>red>> complement? non-digits<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="compose"> compose</span> type: native! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>Returns a copy of a block, evaluating only <a href="./index.html#parenxex">paren!</a> items. Here is an <br>example of a <a href="./index.html#parenxex">paren!</a>, containing 3 elements:<br><br> (2 + 4)<br> <br>Normally, it does not operate on nested blocks.<br><br>The single argument should be a <a href="./index.html#blockxex">block!</a><br><br>Refinements<br> /deep - compose nested blocks. All paren! expressions are evaluated, <br> however deeply they are nested inside [ ].<br> /only - compose a nested block as a single block containing its values, <br> rather than its series of values.<br> /into - put results into a target block, instead of creating a new <br> block. We supply the target block. This is intended for <br> very large blocks, and can result in lower memory usage.<br><br> <br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; compose some blocks</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> compose [unevaluated items 1 + 2 then (3 * 5)]<br>== [unevaluated items 1 + 2 then 15]<br>;nested blocks are not evaluated<br>red>> compose [(1 + 2) [(4 + 5)]]<br>== [3 [(4 + 5)]]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /deep refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [cat [dog (3 * 4) [fish (6 * 7)]]]<br>red>> compose/deep b<br>== [cat [dog 12 [fish 42]]]<br><br>;note the result without /deep<br>red>> compose b<br>== [cat [dog (3 * 4) [fish (6 * 7)]]]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /only refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> powers: [1 2 4 8 16]<br>red>> compose/only [a b c (powers)]<br>;note [...] round powers values<br>;without /only, no [ ]<br>== [a b c [1 2 4 8 16]]<br>red>> compose [a b c (powers)]<br>== [a b c 1 2 4 8 16]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /into refinement a trivial example, insignificant memory use.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [aa bb (3 * 4)]<br><br>;create an empty block<br>red>> answer: copy []<br>== []<br>red>> compose/into b answer<br>== []<br>and here is the result<br>red>> answer<br>== [aa bb 12]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="construct"> construct</span> type: native! Categories: <a href="./index.html#cat-o01">对象</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="context"> context</span> type: function! Categories: <a href="./index.html#cat-o01">对象</a><br><pre>关键字 <a href="./index.html#context">context</a> is a shorter form of <a href="./index.html#make">make</a> <a href="./index.html#objectxex">object!</a>.<br><br>Using <a href="./index.html#context">context</a> it is very easy to "hide" variables and functions from <br>the global naming scope.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show that both forms are equal</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: context [a: 1 b: 2]<br>== make object! [<br> a: 1<br> b: 2<br>]<br><br>red>> y: make object! [a: 1 b: 2]<br>== make object! [<br> a: 1<br> b: 2<br>]<br><br>red>> x = y<br>== true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reference fields in a <a href="./index.html#context">context</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x/a<br>== 1<br><br>red>> x/b<br>== 2<br><br>red>> y/a<br>== 1<br><br>red>> y/b<br>== 2<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a function in a context</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> p: context [x: 5 y: 6 f: function [] [x + y]]<br>== make object! [<br> x: 5<br> y: 6<br> f: func [][x + y]<br>]<br><br>red>> p/f <b style="color: green">; Uses the x and y in the scope of the context</b><br>== 11 <br><br>red>> p/x: 20 <b style="color: green">; Update a field</b><br>== 20<br><br>red>> p/f<br>== 26<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="contextxqm"> context?</span> type: native! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="continue"> continue</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#continue">continue</a> transfers control back to the begin of a loop.<br></pre>例子<pre>repeat n 5 [<br> print ["Before" n]<br> if n < 3 [continue]<br> print ["After" n]<br>]<br><b style="color: blue">Before 1</b><br><b style="color: blue">Before 2</b><br><b style="color: blue">Before 3</b><br><b style="color: blue">After 3</b><br><b style="color: blue">Before 4</b><br><b style="color: blue">After 4</b><br><b style="color: blue">Before 5</b><br><b style="color: blue">After 5</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="copy"> copy</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#copy">copy</a> returns a copy of a <a href="./index.html#seriesxex">series!</a> or <a href="./index.html#bitsetxex">bitset!</a>.<br><br>关键字 <a href="./index.html#copy">copy</a> does not work on single items such as: <br> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#floatxex">float!</a> <a href="./index.html#charxex">char!</a> etc.<br>For these, we can simply use the colon (get word).<br><br>It has one argument of an appropriate type.<br><br>For (potentially large) <a href="./index.html#seriesxex">series!</a>, Red works with references <br>(pointers to <a href="./index.html#seriesxex">series!</a>) rather than directly with the contents.<br><br>Refinements<br> /part - limit the length of the result, <br> where length is a <a href="./index.html#numberxex">number!</a> or <a href="./index.html#seriesxex">series!</a><br> /deep - copy nested values also<br> /types - copy only specific types of non-scalar values.<br></pre>例子<pre>red>> b: [1 2 3 4]<br>== [1 2 3 4]<br><b style="color: green">; Create variable b which points to a new block</b><br><br>red>> b2: b<br>== [1 2 3 4]<br><b style="color: green">; Assign variable b2 to point to the same block that b points to.</b><br><br>red>> b/2: -999<br>== -999<br><b style="color: green">; Modify the block that b points to at position 2.</b><br><br>red>> b<br>== [1 -999 3 4]<br><b style="color: green">; As expected b now points to the changed block</b><br><br>red>> b2<br>== [1 -999 3 4]<br><b style="color: green">; Because b2 points to the same block you see the same change there also!</b><br><br>red>> b: [1 2 3 4]<br>== [1 2 3 4]<br><b style="color: green">; Create variable b which points to a new block.</b><br><br>red>> b2: copy b<br>== [1 2 3 4]<br><b style="color: green">; Create variable b2 which points to a copy of the block b points to.</b><br><br>red>> b/2: -999<br>== -999<br><b style="color: green">; Show that the block that b points to has changed</b><br><br>red>> b2<br>== [1 2 3 4]<br><b style="color: green">; Because of the copy the block b2 points to is not modified this time.</b><br><br>red>> s: "a string"<br>== "a string"<br><b style="color: green">; Create variable s pointing to a string.</b><br><br>red>> s2: copy s<br>== "a string"<br><b style="color: green">; Create variable s2 pointing to a copy of the string that s points to.</b><br><br>red>> a: [22 33 "name" [44 1.34]]<br>== [22 33 "name" [44 1.34]]<br><b style="color: green">; Create variable a that points to a new block.</b><br><br>red>> b: copy a<br>== [22 33 "name" [44 1.34]]<br><b style="color: green">; Create variable b and point it to a new copy to the block that a points to.</b><br><br>red>> b: copy/part a 2<br>== [22 33]<br><b style="color: green">; Only the first 2 items of a are copied!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="cos"> cos</span> type: routine! <pre>This word is a synonym for <a href="./index.html#cosine">cosine</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="cosine"> cosine</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#cosine">cosine</a> returns the trigonometric cosine.<br><br>Has 1 parameter, a <b style="color: blue">number!</b> (representing an angle).<br><br>Refinements:<br> /radians : expects the input angle in radians;<br> without refinement expects the input angle in degrees.<br></pre>例子<pre>cosine 90<br>== 0.0<br><br>cosine/radians pi<br>== -1.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="create-dir"> create-dir</span> type: routine! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="datatypexex"> datatype!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>关键字 <a href="./index.html#datatypexex">datatype!</a> is the "mother" of all Red's datatypes.<br><br>Note that a <a href="./index.html#typesetxex">typeset!</a> can be defined for grouping several datatypes!<br><br>Note that <a href="./index.html#datatypexex">datatype!</a> and <a href="./index.html#typesetxex">typeset!</a> are also a <a href="./index.html#datatypexex">datatype!</a>!<br></pre>例子<pre>red>> ? datatype!<br> action! binary! bitset! block! char! <br> datatype! error! event! file! float! <br> function! get-path! get-word! hash! image! <br> integer! issue! lit-path! lit-word! logic! <br> map! native! none! object! op! <br> pair! paren! path! percent! point! <br> refinement! routine! set-path! set-word! string! <br> time! tuple! typeset! unset! url! <br> vector! word!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="datatypexqm"> datatype?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#datatypexqm">datatype?</a> returns <a href="./index.html#true">true</a> if its argument is a <br><a href="./index.html#datatypexex">datatype!</a> (e.g. <a href="./index.html#integerxex">integer!</a>, <a href="./index.html#charxex">char!</a> etc). <br></pre>例子<pre>例子<br><br>red>> datatype? 123<br>== false<br><br>red>> datatype? integer!<br>== true<br><br>red>> datatype? block!<br>== true <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="debase"> debase</span> type: native! Categories: <a href="./index.html#cat-b01">数字基础</a>, <a href="./index.html#cat-c07">转换</a><br><pre>Documentation can be found with the word <a href="./index.html#enbase">enbase</a>.<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="default-input-completer"> default-input-completer</span> type: unset! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="dehex"> dehex</span> type: native! Categories: <a href="./index.html#cat-c07">转换</a>, <a href="./index.html#cat-f02">格式化</a><br><pre>关键字 <a href="./index.html#dehex">dehex</a> converts URL-style hex encoded (%xx) strings <br>into characters. The argument can be a <a href="./index.html#stringxex">string!</a> or a <a href="./index.html#filexex">file!</a>.<br></pre>例子<pre>red>> dehex "%41BC" <br>== "ABC"<br><b style="color: green">; 41 is hex for B</b><br><br>red>> dehex "www.search.com/for%20this"<br>== "www.search.com/for this"<br><b style="color: green">; Hex 20 is space</b><br><br>red>> dehex %my%20file.txt<br>== "my file.txt"<br><b style="color: green">; file! type</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="difference"> difference</span> type: native! Categories: <a href="./index.html#cat-s02">集合</a><br><pre>关键字 <a href="./index.html#difference">difference</a> returns the elements of two series <br>that are not present in both. <br><br>Both series arguments must be of the same datatype, which <br>can be:<br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#hashxex">hash!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a>.<br><br><a href="./index.html#difference">difference</a> in one of several set-style functions.<br><br>Refinements:<br> /case - use case-sensitive comparison.<br> /skip - treat the <a href="./index.html#seriesxex">series!</a> as fixed size records. <br> Specify the size as an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre>red>> difference [1 2 99 4] [1 2 3 4]<br>== [99 3]<br><br>red>> difference ["cat" "dog"] ["dog" "mouse" "fish"]<br>== ["cat" "mouse" "fish"]<br><br>red>> difference "abcd" "Ab"<br>== "cd"<br><br>red>> difference/case "abcd" "Ab"<br>== "acdA"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="dir"> dir</span> type: unset! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#dir">dir</a> lists the contents of a directory.<br><br>It is tightly related to the word <a href="./index.html#list-dir">list-dir</a>.<br><br>The directory to list to can be:<br> - an absolute <a href="./index.html#path">path</a><br> - a relative <a href="./index.html#pathxex">path!</a><br> <br>If no argument given, it lists the current directory.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using an absolute path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> dir %/e/src<br> 8th/ go/ python/ red/<br> spiderbasic/ <br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using it without an argument lists the current directory</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> dir<br> basehtml.txt colors.txt design/ gensite.red <br> gensite.txt pages/ publish/ redftp.lnk <br> rexec.red tst.red words/ <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="dirxqm"> dir?</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#dirxqm">dir?</a> returns <a href="./index.html#true">true</a> if the supplied name is a valid file <a href="./index.html#pathxex">path!</a>, <br>otherwise returns <a href="./index.html#false">false</a>. <br><br>A valid file <a href="./index.html#pathxex">path!</a> must have a trailing /.<br><br>NOTE <a href="./index.html#dirxqm">dir?</a> does not look in the file system at all. It only tells you if the<br> <a href="./index.html#pathxex">path!</a> is a valid directory <a href="./index.html#pathxex">path!</a> with a trailing slash!<br><br>Has 1 parameter, which must be a valid file <a href="./index.html#pathxex">path!</a>.<br></pre>例子<pre><b style="color: green">; Non-existent directory</b><br><b style="color: green">; Returns false because trailing / is missing</b><br>dir? %/c/rubbish<br>== false<br><b style="color: green">; Returns true because trailing / is present</b><br>dir? %/c/rubbish/<br>== true<br><br><b style="color: green">; Existing directory</b><br><b style="color: green">; Returns false because trailing / is missing</b><br>dir? %/c/windows<br>== false<br><b style="color: green">; Returns true because trailing / is present</b><br>dir? %/c/windows/<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="dirize"> dirize</span> type: function! Categories: <a href="./index.html#cat-c07">转换</a>, <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#dirize">dirize</a> turns its argument into a valid directory.<br><br>The argument can be of <a href="./index.html#filexex">file!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#urlxex">url!</a>.<br><br>Effectively <a href="./index.html#dirize">dirize</a> only appends a trailing / if needed.<br></pre>例子<pre>red>> dirize "/e/src"<br>== "/e/src/" <b style="color: green">; Note trailing / appended</b><br><br>red>> dirize %/e/src<br>== %/e/src/ <b style="color: green">; Note trailing / appended</b><br><br>red>> dirize %/e/src/<br>== %/e/src/ <b style="color: green">; Nothing happened - directory was already valid</b><br><br>red>> dirize %.<br>== %./ <b style="color: green">; Note trailing / appended</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="divide"> divide</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#divide">divide</a> returns the first value divided by the second.<br>This is equivalent to the infix operator <a href="./index.html#xsl">/</a>.<br><br>Has 2 arguments, which must be of the type:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>When a combination of <a href="./index.html#integerxex">integer!</a> and <a href="./index.html#floatxex">float!</a> values are divided, the result <br>is a <a href="./index.html#floatxex">float!</a>.<br><br>When <a href="./index.html#integerxex">integer!</a>s are divided, the result is an <a href="./index.html#integerxex">integer!</a>, truncated toward zero.<br><br>Division by zero produces a run-time error.<br></pre>例子<pre>red>> divide 8 3.0<br>== 2.666666666666667<br><br>red>> divide 8 3<br>== 2<br><br>red>> divide -8 3<br>== -2<br><br>red>> divide 4.5.6 2<br>== 2.2.3<br><br>red>> v: make vector![4 2 8]<br>== make vector! [4 2 8]<br><br>red>> divide v make vector![1 2 3 4]<br>== make vector! [4 1 2]<br><br>red>> v2: make vector![2 2 3 2:]<br>== make vector! [2 2 3]<br><br>red>> divide v v2<br>== make vector! [2 1 2]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="do"> do</span> type: native! Categories: <a href="./index.html#cat-e02">评估</a><br><pre>关键字 <a href="./index.html#do">do</a> evaluates the code in its argument.<br><br>Single argument:<br> 1. can be a script to execute;<br> in that case the /args refinement can be used to specify arguments <br> for that script (a <a href="./index.html#stringxex">string!</a> or a <a href="./index.html#blockxex">block!</a>)<br> 2. can be a <a href="./index.html#stringxex">string!</a> or a <a href="./index.html#blockxex">block!</a> containing Red code to be<br> evaluated<br> <br>Refinements:<br> /args - arguments for script to be invoked <br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Evaluate a script</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; Given a separate script %tst.red:</b><br><br><b style="color: green">; Red []</b><br><b style="color: green">; print "Hi there from %tst.red!"</b><br><b style="color: green">; args: system/script/args</b><br><b style="color: green">; print ["My arguments are:" system/script/args]</b><br><b style="color: green">; if not none? system/script/args [</b><br><b style="color: green">; foreach arg system/script/args [</b><br><b style="color: green">; print ["Arg:" arg]</b><br><b style="color: green">; ]</b><br><b style="color: green">; ]</b><br><br><b style="color: green">; You can evaluate the script without arguments like so:</b><br>red>> do %tst.red<br><b style="color: blue">Hi there from %tst.red!</b><br><b style="color: blue">My arguments are: none</b><br>== none<br><br><b style="color: green">; You can evaluate the script with <a href="./index.html#stringxex">string!</a> argument like so:</b><br>red>> do/args %tst.red "my args"<br><b style="color: blue">Hi there from %tst.red!</b><br><b style="color: blue">My arguments are: my args</b><br><b style="color: blue">Arg: m</b><br><b style="color: blue">Arg: y</b><br><b style="color: blue">Arg: </b><br><b style="color: blue">Arg: a</b><br><b style="color: blue">Arg: r</b><br><b style="color: blue">Arg: g</b><br><b style="color: blue">Arg: s</b><br><br><b style="color: green">; If you need multiple arguments, use a <a href="./index.html#blockxex">block!</a></b><br>red>> do/args %tst.red ["my" "individual" "args"]<br><b style="color: blue">Hi there from %tst.red!</b><br><b style="color: blue">My arguments are: my individual args</b><br><b style="color: blue">Arg: my</b><br><b style="color: blue">Arg: individual</b><br><b style="color: blue">Arg: args</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Evaluate a block</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> blk: [x: 10 y: 20 z: x + y print z]<br>== [x: 10 y: 20 z: x + y print z]<br>red>> do blk<br>30<br>red>> x<br>== 10<br>red>> y<br>== 20<br>red>> z<br>== 30<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Evaluate a string</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; Here we show how to do complex things using do</b><br><br><b style="color: green">; Use variables to contain the name and value for a variable</b><br><b style="color: green">; to be embedded in the object</b><br>red>> var: "vname"<br>== "vname"<br>red>> val: 11<br>== 11<br><br><b style="color: green">; Prepare the string with the code</b><br>red>> str: copy {obj: make object! [}<br>== "obj: make object! ["<br>red>> append str var<br>== "obj: make object! [vname"<br>red>> append str copy {: }<br>== "obj: make object! [vname: "<br>red>> append str val<br>== "obj: make object! [vname: 11"<br>red>> append str copy {]}<br>== "obj: make object! [vname: 11]"<br><br><b style="color: green">; String is now complete</b><br>red>> str<br>== "obj: make object! [vname: 11]"<br><br><b style="color: green">; Evaluate the string</b><br>red>> do str<br>== make object! [<br> vname: 11<br>]<br><br><b style="color: green">; Show that the object now exists:</b><br>red>> obj<br>== make object! [<br> vname: 11<br>]<br>red>> obj/vname<br>== 11<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="do-actor"> do-actor</span> type: unset! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="do-events"> do-events</span> type: unset! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="do-file"> do-file</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="do-safe"> do-safe</span> type: unset! Categories: <a href="./index.html#cat-e02">评估</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="does"> does</span> type: native! Categories: <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#does">does</a> defines a function with no arguments or <br>local variables. <br></pre>例子<pre>welcome: does [<br> print "Welcome"<br> print "to Red"<br>]<br><br>welcome<br><b style="color: blue">Welcome</b><br><b style="color: blue">to Red</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="dump-reactions"> dump-reactions</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="either"> either</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a><br><pre>关键字 <a href="./index.html#either">either</a> evaluates a conditional expression. <br>If the result thereof is <a href="./index.html#true">true</a> the first <a href="./index.html#blockxex">block!</a> will be evaluated. <br>If <a href="./index.html#false">false</a> the second <a href="./index.html#blockxex">block!</a> will be evaluated.<br><br>Has 3 parameters, a conditional expression and 2 <a href="./index.html#blockxex">block!</a>s<br><br><a href="./index.html#either">either</a> returns the value returned from the conditionally evaluated <a href="./index.html#blockxex">block!</a>.<br></pre>例子<pre>either 3 > 2 [print "Indeed!"][print "Nope!"]<br><b style="color: blue">Indeed!</b><br><br>either "ABC" = "abc" [print "The same!"] [print "Different!"]<br><b style="color: blue">The same!</b><br><b style="color: green">; Be careful! Contrary to what is common use in most other programming</b><br><b style="color: green">; languages, Red considers uppercase and lowercase letters to be equal.</b><br><br>either 2 = 2.0 [print "Equal!"][print "Not equal!"]<br><b style="color: blue">Equal!</b><br><br>either 2 == 2.0 [print "Equal!"][print "Not equal!"]<br><b style="color: blue">Not equal!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="emailxex"> email!</span> type: unset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>This <a href="./index.html#datatypexex">datatype!</a> lets us represent literal email addresses. Note that no <br>detailed syntax-checking is performed. It must contain an @ character. An<br> email! is a <a href="./index.html#seriesxex">series!</a>, and can be manipulated character-by-character.<br><br>pre.<br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create some email! types, explore them.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; Create, use type? email?<br>>> e: [email protected]== [email protected]<br>>> type? e<br>== email!<br>>> email? e<br>== true<br>; As a series<br>>> third e<br>== #"b"<br>;limited checking<br>>> em: @x<br>== @x<br>>> type? em<br>== email!<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="emailxqm"> email?</span> type: unset! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>This function returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#emailxex">email!</a> <a href="./index.html#datatypexex">datatype!</a>, <br>otherwise <a href="./index.html#false">false</a>.<br><br>Arguments<br><br>Its single argument can be <a href="./index.html#anytypexex">anytype!</a>.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; explore email? </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>;some 'true' email! values<br>>> em: [email protected]<br>== [email protected]<br>>> email? em<br>== true<br><br>>> email? a@b<br>== true<br><br>>> email? a@<br>== true<br><br>;'false' email literal<br>>> email? "a@b" ;string<br>== false<br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="emptyxqm"> empty?</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#emptyxqm">empty?</a> checks whether a <a href="./index.html#seriesxex">series!</a> is empty.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A few examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> empty? []<br>== true<br><br>red>> empty? [1] <b style="color: green">; Not empty - contains a number</b><br>== false<br><br>red>> empty? [ [] ] <b style="color: green">; Not empty - contains a <a href="./index.html#blockxex">block!</a></b><br>== false<br><br>red>> empty? "x" <b style="color: green">; Not empty - contains a character</b><br>== false<br><br>red>> empty? ""<br>== true<br><br>red>> empty? { "" } <b style="color: green">; Not empty - contains a 4 character string</b> <br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="enbase"> enbase</span> type: native! Categories: <a href="./index.html#cat-b01">数字基础</a>, <a href="./index.html#cat-c07">转换</a><br><pre>关键字 <a href="./index.html#enbase">enbase</a> encodes a string to a a binary-coded string (BASE-64 default).<br>Argument:<br> string to be encoded<br>Refinement:<br> /base - base to be used, e.g. 2, 16 or 64 (default)<br><br>关键字 <a href="./index.html#debase">debase</a> decodes a binary-coded to a binary (BASE-64 default).<br>Argument:<br> binary-coded string to be decoded<br>Refinement:<br> /base - base to be used, e.g. 2, 16 or 64 (default)<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Default base-64 decoding</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: enbase "Red is beautiful"<br>== "UmVkIGlzIGJlYXV0aWZ1bA=="<br><br>red>> y: debase x<br>== #{5265642069732062656175746966756C}<br><br>red>> to string! y<br>== "Red is beautiful"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /base refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: enbase/base "Red is beautiful" 2<br>== {0101001001100101011001000010000001101001011100110010000001100010<br> 0110010101100001011101010111010001101001011001100111010101101100}<br><br>red>> y: debase/base x 2<br>== #{5265642069732062656175746966756C}<br><br>red>> to string! y<br>== "Red is beautiful"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Note that debase needs fixed length chunks!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; for base 2: multiple of 8 bits<br>; for base 16: multiple of 8 bits<br>; for base 64: multiple of 16 bits<br><br>red>> x: enbase/base "A" 2<br>== "01000001"<br><br>red>> y: debase/base x 2 <b style="color: green">; works, because bitstring is a multiple of 8 (bits)</b><br>== #{41}<br><br>red>> to string! y<br>== "A"<br><br>red>> debase/base "01000001" 2 <b style="color: green">; same as contents of y</b><br>== #{41}<br><br>red>> debase/base "010000011" 2 <b style="color: green">; 9 bits - won't work</b><br>== none<br><br>red>> debase/base "0100001" 2 <b style="color: green">; 7 bits - won't work</b><br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="equalxqm"> equal?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#equalxqm">equal?</a> returns <a href="./index.html#true">true</a> if two values are equal. <br><br>This is the functional form of the infix word <a href="./index.html#xeq">=</a>. Look <br>there for more details.<br></pre>例子<pre>red>> equal? [1 2 3] [1 2 3]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="errorxex"> error!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>关键字 <a href="./index.html#errorxex">error!</a> is a <a href="./index.html#datatypexex">datatype!</a>.<br><br>Red supports first class errors via this <a href="./index.html#datatypexex">datatype!</a>. <br><br>Errors can be generated by the user or produced by the system. <br>The error definitions are stored in the system/catalog/errors object.<br><br>Here is how we can view the definitions:<br>red>> help system/catalog/errors<br> system/catalog/errors` is an object! of value:<br> throw object! [code type break return throw continue]<br> note object! [code type no-load]<br> syntax object! [code type invalid missing no-header no-rs-h...<br> script object! [code type no-value need-value not-defined n...<br> math object! [code type zero-divide overflow positive]<br> access object! [code type cannot-open invalid-utf8 no-conne...<br> user object! [code type message]<br> internal object! [code type bad-path not-here no-memory stack...<br>red>> <br> <br>To see the list of errors concerning 'math' for example, we type:<br> ? system/catalog/errors/math<br><br>User errors can be created using 'make' followed by an error integer code, <br>or a block containing the category, error name and (for some errors) an error argument.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Error code</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> make error! 402<br>*** Math error: attempt to divide by zero<br>*** Where: ???<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Error name</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> make error! [math zero-divide]<br>*** Math error: attempt to divide by zero<br>*** Where: ???<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using type, id, and argument</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> make error! [type: 'script id: 'no-value arg1: 'x]<br>*** Script Error: x has no value<br>*** Where: ???<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="errorxqm"> error?</span> type: function! Categories: <a href="./index.html#cat-e01">错误</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#errorxqm">error?</a> returns <a href="./index.html#true">true</a> if the value is of <br>type <a href="./index.html#errorxex">error!</a>. Otherwise <a href="./index.html#false">false</a> is returned.<br><br>This can be used to check the result from <a href="./index.html#try">try</a>.<br></pre>例子<pre>red>> error? try [2 + "3"]<br>== true<br><br>red>> error? try[2 + 3]<br>== false <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="eval-set-path"> eval-set-path</span> type: function! Categories: <a href="./index.html#cat-e02">评估</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="evenxqm"> even?</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#evenxqm">even?</a> returns <a href="./index.html#true">true</a> if a <a href="./index.html#numberxex">number!</a> is even.<br>Else returns <a href="./index.html#false">false</a>.<br><br>Has 1 numeric parameter, which should be an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre>even? -4<br>== true<br><br>even? 77<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="eventxex"> event!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="exclude"> exclude</span> type: native! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#exclude">exclude</a> returns a new value, which is the first <br>argument where elements of the second argument are excluded. <br><br>With strings, difference in case is not significant.<br><br>The argument types can be: <br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#hashxex">hash!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a><br><br>Refinements:<br> /case - use case sensitive comparison.<br> /skip - treat the <a href="./index.html#seriesxex">series!</a> as fixed size records. <br> Specify the size as an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre>red>> exclude [1 2 3 4 5 6] [2 4 6]<br>== [1 3 5]<br><b style="color: green">; Exclude evens</b><br><br>red>> exclude "The Great Wall Of China" "aeiou"<br>== "Th GrWlfCn"<br><b style="color: green">; Exclude vowels, ignoring case</b><br><br>red>> exclude/case "The Great Wall Of China" "aeiou"<br>== "Th GrtWlOfCn"<br><b style="color: green">; Exclude vowels, regarding case - note the letter "O"</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="existsxqm"> exists?</span> type: routine! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#existsxqm">exists?</a> returns <a href="./index.html#true">true</a> if its argument is an existing <a href="./index.html#pathxex">path!</a><br>or <a href="./index.html#false">false</a> otherwise.<br></pre>例子<pre>red>> exists? %/e/drunk<br>== false<br><br>red>> exists? %/e/src<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="exit"> exit</span> type: native! Categories: <a href="./index.html#cat-e03">退出</a>, <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#exit">exit</a> exits a <b style="color: blue">function!</b> without returning a value.<br><br>Has no parameters.<br></pre>例子<pre>fun1: func [p1] [<br> fun2 p1<br> print "fun2 completed"<br>]<br><br>fun2: func [p2] [<br> print "Before exit check ..."<br> if p2 = "exit" [exit]<br> print "After exit check"<br>]<br><br>fun1 "abc"<br><b style="color: blue">Before exit check ...</b><br><b style="color: blue">After exit check</b><br><b style="color: blue">fun2 completed</b><br><br>fun1 "exit"<br><b style="color: blue">Before exit check ...</b><br><b style="color: blue">fun2 completed</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="exp"> exp</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#exp">exp</a> raises E (the natural number) to the power supplied.<br><br>Has one <a href="./index.html#numberxex">number!</a> parameter.<br></pre>例子<pre>x: exp 0<br>== 1.0<br><br>x: exp 1<br>== 2.71828182845905<br><br>exp -1<br>== 0.367879441171442<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="extend"> extend</span> type: native! Categories: <a href="./index.html#cat-m01">图</a>, <a href="./index.html#cat-o01">对象</a><br><pre>关键字 <a href="./index.html#extend">extend</a> extends an <a href="./index.html#objectxex">object!</a> or <a href="./index.html#mapxex">map!</a> value <br>with a list of key and value pairs. The first argument is modified.<br><br>The first argument must be <a href="./index.html#objectxex">object!</a> or <a href="./index.html#mapxex">map!</a>.<br>The second argument must be <a href="./index.html#blockxex">block!</a>, <a href="./index.html#hashxex">hash!</a> or <a href="./index.html#mapxex">map!</a><br><br>Refinements:<br> /case - use case-sensitive comparison<br></pre>例子<pre>red>> users: make map! ["John23" "safe3" "DingSnooker" "mypasswd"]<br>== #(<br> "John23" "safe3"<br> "DingSnooker" "mypasswd"<br>)<br><b style="color: green">; Create a map of 2 users and their passwords.</b><br><br>red>> more-users: make map! ["Jane" "pass123" "Sue" "secret"]<br>== #(<br> "Jane" "pass123"<br> "Sue" "secret"<br>)<br><b style="color: green">; Create another map!</b><br><br>red>> extend users more-users<br>== #(<br> "John23" "safe3"<br> "DingSnooker" "mypasswd"<br> "Jane"... ;truncated output at the console<br><b style="color: green">; Extend the first map! with the second.</b><br><br>red>> print users<br><b style="color: blue">"John23" "safe3"</b><br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><b style="color: blue">"Jane" "pass123"</b><br><b style="color: blue">"Sue" "secret"</b><br><b style="color: green">; Show all the users in the first map!</b><br><br>red>> extend users make map! ["JOHN23" "newPassword"]<br>== #(<br> "John23" "newPassword"<br> "DingSnooker" "mypasswd"<br> ...<br><b style="color: green">; Modify an existing map!</b><br><br>red>> print users<br><b style="color: blue">"John23" "newPassword"</b><br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><b style="color: blue">"Jane" "pass123"</b><br><b style="color: blue">"Sue" "secret"</b><br><b style="color: green">; Note: new password for John23 (case-insensitive)</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="extract"> extract</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#extract">extract</a> extracts a value from a <a href="./index.html#seriesxex">series!</a> at <br>regular intervals, returning a new <a href="./index.html#seriesxex">series!</a>. <br><br>Arguments are:<br> 1. a <a href="./index.html#seriesxex">series!</a><br> 2. a skip size of type <a href="./index.html#integerxex">integer!</a>.<br><br>Refinements:<br> /index - extract from an offset position (<a href="./index.html#integerxex">integer!</a>).<br> /into - we provide an output <a href="./index.html#seriesxex">series!</a> instead <br> of creating a new one. <br> The results will be appended to the <a href="./index.html#seriesxex">series!</a>.<br></pre>例子<pre>red>> extract [1 2 3 4 5 6 7] 3<br>== [1 4 7]<br><b style="color: green">; Extracts every 3rd element of a block!</b>.<br><br>red>> extract "abcdefghij" 2<br>== "acegi"<br><b style="color: green">; Extracts every 2nd element of a string!</b>.<br><br>red>> extract/index "abcdefghij" 2 4<br>== "dfhj"<br><b style="color: green">; Start from an offset position (position = 4 at char! #"d")</b><br><br>red>> buffer: []<br>== []<br><b style="color: green">; Create an empty buffer for results.</b><br><br>red>> extract/into [1 2 3 4 5 6 7] 2 buffer<br>== [1 3 5 7]<br><br>red>> extract/into [10 20 30 40 50 60] 2 buffer<br>== [1 3 5 7 10 30 50]<br><br>red>> buffer<br>== [1 3 5 7 10 30 50]<br><b style="color: green">; The accumulated results in the buffer.</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="extract-boot-args"> extract-boot-args</span> type: function! Categories: <a href="./index.html#cat-s05">系统相关</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="false"> false</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>关键字 <a href="./index.html#false">false</a> represents the boolean value <a href="./index.html#false">false</a>. <br>Is of datatype <a href="./index.html#logicxex">logic!</a><br></pre>例子<pre>1 = 2<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="fifth"> fifth</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#fifth">fifth</a> returns the fifth value in a <a href="./index.html#seriesxex">series!</a>. <br><br>The argument can be one of: <br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#tuplexex">tuple!</a><br><br>If there is no fifth item, then <a href="./index.html#none">none</a> is returned.<br></pre>例子<pre>red>> fifth [1 2 3 4 5 6 7]<br>== 5<br><br>red>> fifth "ABCDEFG"<br>== #"E"<br><br>red>> fifth 12.16.13.15.22<br>== 22<br><br>red>> fifth [1 2 3]<br>== none<br><b style="color: green">; No fifth element found</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="filexex"> file!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>关键字 <a href="./index.html#filexex">file!</a> is a <a href="./index.html#datatypexex">datatype!</a>; it can be a: <br> file name<br> directory name<br> directory <a href="./index.html#pathxex">path!</a>. <br> <br>A file! is a type of <a href="./index.html#seriesxex">series!</a>, rather like a string. <br>Note that this type is concerned with file names and places, rather than the contents of a file.<br><br>Here are some file! examples<br> %file.txt<br> %directory/<br> %directory/my%20stuff/file.txt<br> %"directory/my stuff/file.txt"<br> %/c/windows/softwaredistribution<br><br>Notes:<br> - a <a href="./index.html#filexex">file!</a> literal must always start with a percent sign %<br> - use forward slashes / (Unix style); back slashes will be automagically converted to /<br><br>Unusual characters in file names must be encoded with a % hexadecimal number, <br>such as %20 for space. Thus, my%20stuff refers to "my stuff"; alternatively, <br>we may enclose them in "quotes", and Red generates the hexadecimal codes for us.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The file! as a series!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> find %top/work/red/demo.txt "red"<br>== %red/demo.txt<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a file! to manipulate contents: load, save</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> save %demo.txt "some data for a file"<br><br>red>> print load %demo.txt<br><b style="color: blue">some data for a file</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="filexqm"> file?</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#filexqm">file?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#filexex">file!</a>. <br><br>In Red, a <a href="./index.html#filexex">file!</a> type value is preceded by %. <br>If spaces are needed in a file name, enclose it in quotes or use hex %20, as in:<br> %"my files/"<br> %/my%20files/<br><br>In Windows the drive letter is part of the <a href="./index.html#pathxex">path!</a>, like so:<br> %/c/windows/system32/xyz.dll<br> <br>Absolute <a href="./index.html#pathxex">path!</a>s start with %/ and relative <a href="./index.html#pathxex">path!</a>s just with %.<br></pre>例子<pre>red>> my-data: %/top/personal/stuff.txt<br>== %/top/personal/stuff.txt<br><b style="color: green">; Absolute path</b><br><br>red>> file? my-data<br>== true<br><br>red>> file? %work.doc<br>== true<br><b style="color: green">; Relative path</b><br><br>red>> file? %/folder1/folder2/<br>== true<br><b style="color: green">; A path can also be a directory</b><br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="find"> find</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#find">find</a> returns the <a href="./index.html#seriesxex">series!</a> from the position where a value <br>is found, or <a href="./index.html#none">none</a>. <br><br>Arguments:<br> 1. the item to be searched can be:<br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#any-objectxex">any-object!</a> <a href="./index.html#mapxex">map!</a> <a href="./index.html#nonexex">none!</a><br> 2. the value to be found can be <a href="./index.html#any-typexex">any-type!</a><br><br>Refinements<br> /part - limit length of search to a length or to a position in the series. <br> The argument must be <a href="./index.html#numberxex">number!</a> or <a href="./index.html#seriesxex">series!</a><br> /only - Treat a series search value as a single value<br> /case - Perform a case-sensitive search.<br> /same - Use "same?" as comparator.<br> /any - Use * and ? wildcards in string searches. (Not available yet)<br> /with - Use custom wildcards in place of * and ?. (Not available yet)<br> /skip - Treat the series as fixed size records. Supply a size <a href="./index.html#integerxex">integer!</a><br> /last - Find the last occurrence of value, from the tail.<br> /reverse - Find the last occurrence of value, from the current index.<br> /tail - Return the tail of the match found, rather than the head.<br> /match - Match at current index only and return tail of match.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Simple finds - string, block, series, returns the series from the found point</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> find "The catfish" "cat"<br>== "catfish"<br><br>red>> find "The catfish" "CAT" <b style="color: green">; find is case-insensitive by default</b><br>== "catfish"<br><br>red>> find "The catfish" "dog" <b style="color: green">; returns none if not found</b><br>== none<br><br>red>> find [11 22 33 44 55 66] [ 33 44]<br>== [33 44 55 66]<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /part refinement with a length = limit on the region where the search takes place</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> find/part "The dog" "The" 2 <b style="color: green">; search region restricted to "Th"</b><br>== none<br><br>red>> find/part "The dog" "he" 3 <b style="color: green">; search region restricted to "The"</b><br>== "he dog"<br><br>red>> s: [1 2 3 4 5 6 7 ]<br>== [1 2 3 4 5 6 7]<br><br>red>> place: find s 3 <b style="color: green">; find "3" in series "s"</b><br>== [3 4 5 6 7]<br><br>red>> index? place<br>== 3<br><br>red>> find/part s 2 place <b style="color: green">; search restriced to pos 1 up to index? place</b><br>== [2 3 4 5 6 7]<br><br>red>> find/part s 4 place <b style="color: green">; 4 is beyond the index of place</b><br>== none<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /only refinement (not valid for strings)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [11 22 [33 44] 55 66]<br>== [11 22 [33 44] 55 66]<br><br>red>> find/only s [33 44] <b style="color: green">; treat the nested block as one item</b><br>== [[33 44] 55 66]<br><br>red>> find s [33 44] <b style="color: green">; without /only we cannot find it</b><br>== none<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /skip refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; In this cas FIND treats the series as a set of records, where each record<br>; has a fixed size. FIND will only try to match against each first item of such a record.<br><br>red>> s: [11 22 33 44 55 66]<br>== [11 22 33 44 55 66]<br><br>; Next examples have a record size of 2<br><br>red>> find/skip s 22 2 <b style="color: green">; 22 is the second item of a record. So, no match</b><br>== none<br><br>red>> find/skip s 33 2 <b style="color: green">; 33 is the first item of a record. So, a match</b><br>== [33 44 55 66]<br><br>; Next examples have a record size of 3<br><br>red>> find/skip s 22 3 <b style="color: green">; 22 is the second item of a record. So, no match</b><br>== none<br><br>red>> find/skip s 33 3 <b style="color: green">; 33 is the third item of a record. So, no match</b><br>== none<br><br>red>> find/skip s 44 3 <b style="color: green">; 33 is the first item of a record. So, a match</b><br>== [44 55 66]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /last refinement - search from the end, backwards</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [11 22 33 44 33 22 11]<br>== [11 22 33 44 33 22 11]<br><br>red>> find/last s 22<br>== [22 11]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /reverse refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "A1A2A3A4"<br>== "A1A2A3A4"<br><br>red>> s: at s 5 <b style="color: green">; position the index halfway the string</b><br>== "A3A4"<br><br>red>> find/reverse s "A" <b style="color: green">; searh backwards from current index</b><br>== "A2A3A4"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /tail refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; Normally FIND returns the result INCLUDING the matched item.<br>; With /TAIL the result returned is the part AFTER the matching search argument.<br><br>red>> find/tail "ABCDEF" "BC"<br>== "DEF" <b style="color: green">; result does NOT include the search argument</b><br><br>red>> find "ABCDEF" "BC"<br>== "BCDEF" <b style="color: green">; result DOES include the search argument</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /match refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; Match always tries to match against the beginning of the series.<br>; Also the result is EXCLUSIVE the search argument.<br><br>red>> find/match "ABCDE" "A" <b style="color: green">; mact, because "A" found at begin of string</b><br>== "BCDE"<br><br>red>> find/match "ABCDE" "D" <b style="color: green">; no match - "D" not at beginning of string</b><br>== none<br><br>red>> find/match "ABCDE" "AB" <b style="color: green">; match - search argument is at start of string</b> <br>== "CDE"<br><br>red>> find/match "ABCDE" "DE" <b style="color: green">; no match - search argument is beyond start of string</b><br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="first"> first</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#first">first</a> returns the first value in a <a href="./index.html#seriesxex">series!</a>. <br><br>The argument can be one of: <br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#pairxex">pair!</a><br><br>If there is no first item, <a href="./index.html#none">none</a> is returned.<br></pre>例子<pre>red>> first [3 4 5]<br>== 3<br><b style="color: green">; First of a block!.</b><br><br>red>> first "ABC"<br>== #"A"<br><b style="color: green">; First of a string!.</b><br><br>red>> first []<br>== none<br><b style="color: green">; There is no first value here.</b><br><br>red>> first 22.33.44<br>== 22<br><b style="color: green">; First of a tuple!.</b><br><br>red>> first 200x400<br>== 200<br><b style="color: green">; First of a pair!.</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="flip-exe-flag"> flip-exe-flag</span> type: function! Categories: <a href="./index.html#cat-s05">系统相关</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="floatxex"> float!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#floatxex">float!</a> represents a <a href="./index.html#numberxex">number!</a> type containing <br>IEEE-754 64-bit floating point numbers.<br><br>In literals the e-notation can be used.<br><br>Floats that cannot be represented are NaN (Not a Number).<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> 3e2<br>== 300.0<br><br>red>> 3.5 / 2.1<br>== 1.666666666666667<br><br>red>> 4 / 2.0<br>== 2.0<br><br>red>> 3e2 + 1<br>== 301.0<br><br>red>> 1.0 / 0<br>*** Math error: attempt to divide by zero<br>*** Where: /<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="floatxqm"> float?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#floatxqm">float?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#floatxex">float!</a> type, <br>otherwise <a href="./index.html#false">false</a>.<br></pre>例子<pre>red>> float? 1.23<br>== true<br><br>red>> float? 3<br>== false<br><b style="color: green">; No decimal point</b><br><br>red>> float? 3.0<br>== true<br><br>red>> float? "3"<br>== false<br><b style="color: green">; Is a string</b><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="forall"> forall</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#forall">forall</a> evaluates its body, moving through the <br>provided <a href="./index.html#seriesxex">series!</a> one position at a time. <br><br>Note that it does not use a single value from the <a href="./index.html#seriesxex">series!</a> for each <br>repetition, as <a href="./index.html#foreach">foreach</a> does. Instead, it increments the index position <br>of the <a href="./index.html#seriesxex">series!</a>.<br></pre>例子<pre>numbers: [1 2 -4 8 -16]<br><br>forall numbers [<br> print numbers<br>]<br><b style="color: blue">1 2 -4 8 -16</b><br><b style="color: blue">2 -4 8 -16</b><br><b style="color: blue">-4 8 -16</b><br><b style="color: blue">8 -16</b><br><b style="color: blue">-16</b><br><br>forall numbers [<br> if (first numbers) >= 0 [<br> print first numbers<br> ]<br>]<br><b style="color: blue">1</b><br><b style="color: blue">2</b><br><b style="color: blue">8</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="foreach"> foreach</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#foreach">foreach</a> evaluates its body (a <a href="./index.html#blockxex">block!</a>) for each value in a <a href="./index.html#seriesxex">series!</a>.<br><br>A variable (or <a href="./index.html#blockxex">block!</a> of variables) must be provided, and <a href="./index.html#foreach">foreach</a> will take<br>each value in the <a href="./index.html#seriesxex">series!</a> as the iteration proceeds.<br><br>The arguments are:<br> 1. a variable or <a href="./index.html#blockxex">block!</a> of variables.<br> 2. a <a href="./index.html#seriesxex">series!</a>, e.g. <a href="./index.html#blockxex">block!</a>, <a href="./index.html#vectorxex">vector!</a>, <a href="./index.html#stringxex">string!</a> etc<br> 3. a <a href="./index.html#blockxex">block!</a> - the body, executed for each iteration<br></pre>例子<pre>foreach country ["China" "Vietnam" "Thailand"] [<br> print country<br>]<br><b style="color: blue">China</b><br><b style="color: blue">Vietnam</b><br><b style="color: blue">Thailand</b><br><b style="color: green">; Assigns the values in the block in turn to the variable "country"</b><br><br>country-series: ["China" "Vietnam" "Thailand"]<br>foreach country country-series [<br> print country<br>]<br><b style="color: blue">China</b><br><b style="color: blue">Vietnam</b><br><b style="color: blue">Thailand</b><br><b style="color: green">; Instead of using a literal block, you can also use a variable holding a block.</b><br><br>foreach character "Red" [<br> print character<br>]<br><b style="color: blue">R</b><br><b style="color: blue">e</b><br><b style="color: blue">d</b><br><b style="color: green">; Prints in turn each cgaracter of the string specified.</b><br><br>capital-series: ["China" "Beijing" "USA" "Washington" "UK" "London"]<br>foreach [country city] capital-series [<br> prin country<br> prin " - capital is - "<br> print city<br>]<br><b style="color: blue">China - capital is - Beijing</b><br><b style="color: blue">USA - capital is - Washington</b><br><b style="color: blue">UK - capital is - London</b><br><b style="color: green">; The prin function prints without outputting a newline.</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="forever"> forever</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#forever">forever</a> evaluates a <a href="./index.html#blockxex">block!</a> body repeatedly (= forever).<br>关键字 <a href="./index.html#break">break</a> can be used to exit the loop if required.<br></pre>例子<pre>forever [<br> r: random 10<br> print r<br> if r > 5 [break]<br>]<br><b style="color: blue">3</b><br><b style="color: blue">7</b><br><b style="color: green">; This ends when r gets a value higher than 5</b><br><br>forever [<br> print "hi"<br>]<br><b style="color: blue">"hi"</b><br><b style="color: green">; The line above will be printed eternally ...</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="form"> form</span> type: action! Categories: <a href="./index.html#cat-c07">转换</a>, <a href="./index.html#cat-f02">格式化</a><br><pre>The <a href="./index.html#form">form</a> word converts a value to a <a href="./index.html#stringxex">string!</a>, in a user-friendly format.<br><br>NOTE that, depending on the type, the resulting text might not contain extra<br> type information (such as [ ] { } and "") as would be produced by <a href="./index.html#mold">mold</a>.<br><br>It has one argument, a value.<br><br>Refinements:<br> /part - an <a href="./index.html#integerxex">integer!</a> value limiting the length of the result <a href="./index.html#stringxex">string!</a><br></pre>例子<pre>Because the Red console has an effect on formatting, we will use print.<br><br>red>> print form "ABCDEFG"<br><b style="color: blue">ABCDEFG</b><br><br>red>> print form/part "ABCDEFG" 2<br><b style="color: blue">AB</b><br><br>red>> print form #"Z"<br><b style="color: blue">Z</b><br><br>red>> print form {The Great<br> Wall Of<br> China}<br><b style="color: blue">The Great</b><br><b style="color: blue">Wall Of</b><br><b style="color: blue">China</b><br><br>red>> print form [1 2 3 4 5 6]<br><b style="color: blue">1 2 3 4 5 6</b><br><br>red>> print form/part [1 2 3 4 5 6] 4<br><b style="color: blue">1 2</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="fourth"> fourth</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#fourth">fourth</a> returns the fourth value in a <a href="./index.html#seriesxex">series!</a>. <br><br>The argument can be one of: <br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#tuplexex">tuple!</a><br><br>If there is no fourth item, <a href="./index.html#none">none</a> is returned.<br></pre>例子<pre>red>> fourth [1 2 3 4 5 6 7]<br>== 4<br><br>red>> fourth "ABCDEFG"<br>== #"D"<br><br>red>> fourth [1 2 3]<br>== none<br><b style="color: green">; No fourth value found!</b><br><br>red>> fourth 22.33.1.255<br>== 255<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="func"> func</span> type: native! Categories: <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#func">func</a> is used to create functions. <br><br>Items (variables etc) referred to in the body of a <a href="./index.html#func">func</a> are assumed to be global. <br><br>In almost any case it is better to use the word <a href="./index.html#function">function</a>.<br><br>Arguments:<br> 1. <a href="./index.html#blockxex">block!</a> of:<br> - function arguments<br> - refinements<br> - local variable definitions <br> 2. the function body, a <a href="./index.html#blockxex">block!</a><br></pre>例子<pre><b style="color: green">; Using a global variable</b><br>add-up: func[a b] [<br> number: a + b<br> print number <b style="color: green">; Global</b><br>]<br>number: 0 <b style="color: green">; Global</b><br>add-up 3 5<br>print number <b style="color: green">; Global</b><br><b style="color: blue">8</b> <b style="color: green">; Global</b><br><b style="color: blue">8</b> <b style="color: green">; Global</b><br><br><b style="color: green">; Shadowing a global variable</b><br>add-up2: func [a b /local number] [<br> number: a + b<br> print number <b style="color: green">; Local</b><br>]<br>number: 20 <b style="color: green">; Global</b><br>add-up2 3 5<br>print number <b style="color: green">; Global</b><br><b style="color: blue">8</b> <b style="color: green">; Local</b><br><b style="color: blue">20</b> <b style="color: green">; Local</b><br><br><b style="color: green">; Using a refinement without a value</b><br>add-up3: func [a b /neg /local temp] [<br> temp: a + b<br> <b style="color: green">; Note that a refinement is a boolean</b><br> if neg [<br> temp: temp * -1<br> ]<br> print temp<br>]<br>add-up3 3 5<br><b style="color: blue">8</b><br>add-up3/neg 3 5<br><b style="color: blue">-8</b><br><br><b style="color: green">; Using a refinement with a value</b><br>add-up4: func [a b /c cval /local temp] [<br> temp: a + b<br> if c [<br> temp: temp + cval<br> ]<br> print temp<br>]<br>add-up4 3 5<br><b style="color: blue">8</b><br>add-up4/c 3 5 6<br><b style="color: blue">14</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="function"> function</span> type: native! Categories: <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#function">function</a> is used to define functions. <br><br>Functions can accept arguments and return a result. <br><br>The general pattern of defining a function is:<br> my-function-name: function [spec] [<br> body i.e. code<br> ]<br><br>In the spec part the following can be present:<br><br> - definition of arguments in the form:<br> name [type1 type2 ...]<br><br> - definition a possible return types:<br> return: [type1 type2 ...]<br><br> - /local followed by all variables that should be local to the <br> <a href="./index.html#function">function</a><br> Note this should not be used here, because <a href="./index.html#function">function</a><br> applies /local implicitly to all variables, unless<br> /extern is specified<br><br> - /extern followed by all variables that should not be defined as<br> local. This means that these variables should be<br> available in global scope.<br> <br>As stated above: variables referred to in the body of a <a href="./index.html#function">function</a> are <br>assumed to be local. <br><br>In almost any case it is better to use the word <a href="./index.html#function">function</a> than <a href="./index.html#func">func</a>,<br>because <a href="./index.html#function">function</a> provides out of the box what has to be specified<br>explicitly with <a href="./index.html#func">func</a> otherwise.<br><br>If we try to pass wrong types to a function, a run-time message <br>occurs during interpretation, or at execution time if we compiled it; the <br>lack of a compilation error message concerning invalid argument types <br>is due to the flexible way that Red handles types.<br><br>Returning from a function:<br><br> - exit - return without avalue<br><br> - return - return with a value<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Shadowing a global variable</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>add-up2: function [a b ] [<br> number: a + b<br> print number <b style="color: green">; Local</b><br>]<br><br>number: 20 <b style="color: green">; Global</b><br><br>red>> add-up2 3 5<br><b style="color: blue">8</b> <b style="color: green">; Local</b><br><br>red>> print number<br><b style="color: blue">20</b> <b style="color: green">; Global</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Specify the type of the arguments</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>show-bigger: function [<br> a[integer!]<br> b[integer!]<br>][<br> either a > b [<br> print a<br> ][<br> print b<br> ]<br>]<br><br>red>> show-bigger 44 55<br>55<br><br>red>> show-bigger 4 + 5 10<br>10<br><br>red>> show-bigger 4<br>*** Script error: show-bigger is missing its b argument<br>*** Where: show-bigger<br><br>red>> show-bigger "x" "y"<br>*** Script error: show-bigger does not allow string! for its a argument<br>*** Where: show-bigger<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Allow multiple types for an argument - Generic <a href="./index.html#function">function</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>show-bigger: function [<br> a[integer! float!]<br> b[integer! float!]<br>]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Or use a type that has other types as its subclasses</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>show-bigger: function [<br> a[number!]<br> b[number!]<br>]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Returning a value from a <a href="./index.html#function">function</a> by default</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>a-result: function[][<br> 39<br> 40 + 2 <b style="color: green">; Last expression in a <a href="./index.html#function">function</a> is the return value</b><br>]<br><br>red>> print a-result<br><b style="color: blue">42</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Returning a value from a <a href="./index.html#function">function</a> using <a href="./index.html#return">return</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>a-result: function[][<br> 39<br> return 40 + 2<br>]<br><br>red>> print a-result<br><b style="color: blue">42</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using the <a href="./index.html#return">return</a>ed value in an expression</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>bigger: function [<br> a[number!]<br> b[number!]<br>][<br> either a > b [<br> a<br> ][<br> b<br> ]<br>]<br><br>red>> 2 + bigger 3 4<br>6<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sometimes we need parenthesis when calling a function</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> bigger (bigger 3 4) (bigger 5 6)<br>6<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; But most of the time it works without parenthesis</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> bigger bigger 4 5 6<br>6<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Pass by value / by reference</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; When we pass scalar types (i.e. single items, such as a <a href="./index.html#numberxex">number!</a>,</b> <br><b style="color: green">; a <a href="./index.html#charxex">char!</a>, a <a href="./index.html#pairxex">pair!</a>) as arguments, a copy of their value is passed</b><br><b style="color: green">; to the <a href="./index.html#functionxex">function!</a>.</b> <br><br><b style="color: green">; When we pass a <a href="./index.html#seriesxex">series!</a> a reference is passed instead. The reason is</b><br><b style="color: green">; that <a href="./index.html#seriesxex">series!</a> can be quite large; copying them would cost too much.</b><br><br><b style="color: green">; Passing by reference makes it possible to change the <a href="./index.html#seriesxex">series!</a> from</b><br><b style="color: green">; within a <a href="./index.html#functionxex">function!</a>.</b><br><br><b style="color: green">; Here an example - the <a href="./index.html#seriesxex">series!</a> will be changed in global scope!</b><br><br>my-append: function [data-block [block!] ][<br> append data-block -999<br>]<br><br>red>> numbers: [45 33 87 55]<br>== [45 33 87 55]<br><br>red>> my-append numbers<br>== [45 33 87 55 -999]<br><br>red>> numbers<br>== [45 33 87 55 -999]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#seriesxex">series!</a> local to a <a href="./index.html#functionxex">function!</a> - closing over a <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; A local <a href="./index.html#seriesxex">series!</a> when instantiated from a <a href="./index.html#seriesxex">series!</a> without</b><br><b style="color: green">; copying, will keep its value over function calls!</b><br><b style="color: green">; Note that this also applies to <a href="./index.html#stringxex">string!</a>s</b><br><br>x-s: function[] [<br> xblock: [] <b style="color: green">; The [] is modified each time calling the <a href="./index.html#functionxex">function!</a></b> <br> append xblock "X"<br> print mold xblock<br>]<br><br>red>> x-s<br><b style="color: blue">["X"]</b><br><br>red>> x-s<br><b style="color: blue">["X" "X"]</b><br><br>red>> x-s<br><b style="color: blue">["X" "X" "X"]</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Avoid the previous situation by copying the <a href="./index.html#seriesxex">series!</a> to initialize it</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>x-s: function[] [<br> xblock: copy [] <b style="color: green">; On each call we get a fresh new <a href="./index.html#blockxex">block!</a></b> <br> append xblock "X"<br> print mold xblock<br>]<br><br>red>> x-s<br>["X"]<br><br>red>> x-s<br>["X"]<br><br>red>> x-s<br>["X"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Comments in <a href="./index.html#functionxex">function!</a> definitions</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>bigger: function [ <br> "return the bigger of 2 numbers"<br> arg1[number!] "first number argument"<br> arg2[number!] "second number argument"<br>][<br> either arg1 > arg2 [<br> arg1<br> ][<br> arg2<br> ]<br>]<br><br>red>> help bigger<br><b style="color: blue">USAGE:</b><br><b style="color: blue"> bigger arg1 arg2</b><br><b style="color: blue">DESCRIPTION:</b><br><b style="color: blue"> return the bigger of 2 numbers.</b> <b style="color: green">; Our docstring</b><br><b style="color: blue"> bigger is of type: function!</b><br><b style="color: blue">ARGUMENTS:</b><br><b style="color: blue"> arg1 [number!] => first number argument.</b><br><b style="color: blue"> arg2 [number!] => second number argument.</b><br><b style="color: blue">REFINEMENTS:</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using refinements as options</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a: [1 9 3 8 2 7 5 4 6]<br>== [1 9 3 8 2 7 5 4 6]<br><br>red>> sort a <b style="color: green">; No refinement</b> <br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> a <b style="color: green">; Note that <a href="./index.html#sort">sort</a> changes the <a href="./index.html#seriesxex">series!</a></b><br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> sort/reverse a <b style="color: green">; With /reverse refinement</b><br>== [9 8 7 6 5 4 3 2 1]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using refinements needing an extra argument</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> sort/part a 4 <b style="color: green">; /part refinement needs an extra argument</b><br>== [6 7 8 9 5 4 3 2 1]<br><br>red>> sort/reverse/part a 4 <b style="color: green">; Combining these 2 refinements</b><br>== [9 8 7 6 5 4 3 2 1]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using the /neg refinement as an option</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>add-up3: function [a b /neg] [<br> temp: a + b<br> <b style="color: green">; Note that a refinement is a boolean</b><br> if neg [<br> temp: temp * -1<br> ]<br> return temp<br>]<br><br>red>> add-up3 3 5<br>8<br><br>red>> add-up3/neg 3 5<br>-8<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using refinements /c and /d with extra arguments</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>add-up4: function [a b /c cval /d dval] [<br> temp: a + b<br> <b style="color: green">; Note that a refinement is a boolean</b> <br> if c [<br> temp: temp + cval<br> ]<br> if d [<br> temp: temp - dval<br> ]<br> return temp<br>]<br><br>red>> add-up4 3 5<br>== 8<br><br>red>> add-up4/c 3 5 3<br>== 11<br><br>red>> add-up4/d 3 5 3<br>== 5<br><br>red>> add-up4/c/d 3 5 4 5 <b style="color: green">; Note that /c = 4 and /d = 5</b><br>== 7<br><br>red>> add-up4/d/c 3 5 4 5 <b style="color: green">; Note that /c = 5 and /d = 4</b><br>== 9<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Forward referencing a <a href="./index.html#functionxex">function!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; By default you should define your <a href="./index.html#functionxex">function!</a>s at the top of your</b><br><b style="color: green">; program and call them later on.</b><br><br><b style="color: green">; However, this is not required if and only if the call is from within</b><br><b style="color: green">; another <a href="./index.html#functionxex">function!</a></b><br><br>show-all: function [] [<br> print "Powers of ten:"<br> display-powers <b style="color: green">; Works from inside a <a href="./index.html#functionxex">function!</a> body</b><br>]<br><br>display-powers: function[] [<br> print [10 1000 10000 100000]<br>]<br><br>red>> show-all<br><b style="color: blue">Powers of ten:</b><br><b style="color: blue">10 1000 10000 100000</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Assigning functions to variables - use a prefix colon</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> sorteren: :sort<br>== make action! [[<br> {Sorts a series (modified); default sort or...<br><br>red>> sorteren [2 5 3 1 4]<br>== [1 2 3 4 5]<br><br>red>> sorteren/reverse [2 5 3 1 4]<br>== [5 4 3 2 1]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Returning from a function without a result value</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>void: function [] [<br> exit<br>]<br><br>red>> mold void<br>== "unset"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Returning a result value</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>val: function [] [<br> return "My message"<br>]<br><br>red>> val<br>== "My message"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /extern refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>test: function [<br> /extern var1 <br>] [<br> var1: 11<br> var2: 22<br>]<br><br>red>> var1: 1<br>== 1<br><br>red>> var2: 2<br>== 2<br><br>red>> test<br>== 22<br><br>red>> var1<br>== 11 <b style="color: green">; Changed because of /extern - global scope</b><br><br>red>> var2<br>== 2 <b style="color: green">; Shadowed - global scope not changed</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="functionxex"> function!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a>, <a href="./index.html#cat-f03">函数</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="functionxqm"> function?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#functionxqm">function?</a> returns <a href="./index.html#true">true</a> if its argument is a function, <br>otherwise <a href="./index.html#false">false</a>.<br><br>The single argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Make a function, try it, use function?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> f: function [] [print "in function"]<br>== func [][print "in function"]<br><br>red>> f<br>in function <b style="color: green">; The function works</b><br><br>red>> function? :f <b style="color: green">; The colon is needed to prevent execution</b><br>== true <b style="color: green">; Definitely a function</b><br><br>red>> function? f <b style="color: green">; Is the return value of the function call a function?</b><br><b style="color: blue">in function</b><br>== false<br><br>red>> f2: func [] [func [] [print "Hi!"]]<br>== func [][func [] [print "Hi!"]]<br><br>red>> function? :f2 <b style="color: green">; F2 itself is a function</b><br>== true<br><br>red>> function? f2 <b style="color: green">; Executing F2 also returns a function</b><br>== true<br><br>red>> function? :first <b style="color: green">; Is FIRST a function?</b><br>== true<br><br>red>> a: 3<br>== 3<br><br>red>> function? a <b style="color: green">; Is A a function?</b><br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get"> get</span> type: native! Categories: <a href="./index.html#cat-w01">标识符操作</a><br><pre>关键字 <a href="./index.html#get">get</a> returns the value a word refers to. <br>Use <a href="./index.html#in">in</a> to get a word value inside an <a href="./index.html#objectxex">object!</a> <br><br>Arguments<br> The single argument is a <a href="./index.html#wordxex">word!</a> or a <a href="./index.html#pathxex">path!</a>.<br><br>Refinements<br> /any - If word has no value, return UNSET rather than causing an error.<br> /case - Use case-sensitive comparison (path only).<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a word (w) with get</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> w: 123<br>== 123<br><br>red>> get 'w <b style="color: green">; Use ' (quote) to prevent evaluation of w</b><br>== 123<br><br>red>> get first [w] <b style="color: green">; Use [ ] to prevent evaluation of w</b><br>== 123<br><br>red>> get w <b style="color: green">; w does not contain the name of an existing variable</b><br>*** Script Error: get does not allow integer! for its word argument<br>*** Where: get<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a word (w) with get which contains a variable name</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: 12<br>== 12<br><br>red>> w: 'x<br>== x<br><br>red>> get w<br>== 12<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using get with a path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [11 22 33 44 55]<br>== [11 22 33 44 55]<br><br>red>> place: 3<br>== 3<br><br>red>> get first [b/:place]<br>== 33<br><br>red>> get 'b/:place<br>== 33 <br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using get indirect with a path</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: 12<br>== 12<br><br>red>> b: [11 22 x 44 55]<br>== [11 22 x 44 55]<br><br>red>> get first [b/:place]<br>== x<br><br>red>> get 'b/:place<br>== x<br><br>red>> get get first [b/:place]<br>== 12<br><br>red>> get get 'b/:place<br>== 12<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-current-dir"> get-current-dir</span> type: routine! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#get-current-dir">get-current-dir</a> returns the current directory the program is using. <br><br>When a program begins executing, its current directory is set to the one it is <br>stored in, but the current directory can be changed during run time.<br></pre>例子<pre><b style="color: green">; The example program is filefolders.exe, stored in this file structure:</b><br><b style="color: green">; C:\red\file-dir-tests\</b><br><b style="color: green">; filefolders.exe</b><br><b style="color: green">; folder1A\</b><br><b style="color: green">; folder1B\</b><br><b style="color: green">; folder1C\</b><br><br>print ["Current-dir:" get-current-dir]<br><a href="./index.html#Current-dir: C:\red\file-dir-tests">Current-dir: C:\red\file-dir-tests</a><br><br>cd %folder1A<br>print ["Current-dir:" get-current-dir]<br><a href="./index.html#Current-dir: C:\red\file-dir-tests\folder1A">Current-dir: C:\red\file-dir-tests\folder1A</a><br><br>cd %..<br>print "Current-dir: "print get-current-dir<br><a href="./index.html#Current-dir: C:\red\file-dir-tests">Current-dir: C:\red\file-dir-tests</a><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-env"> get-env</span> type: native! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>word <a href="./index.html#get-env">get-env</a> returns the value of an OS environment variable of the current process,<br>as a <a href="./index.html#string1">string1</a>. <br><br>To get all environment variables/values, use <a href="./index.html#list-env">list-env</a>.<br><br>Arguments<br> The single argument can be any string or any word.<br> NOTE: the case of the argument is not relevant!<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Get the value of the "USERPROFILE" environment variable</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> get-env "USERPROFILE" <b style="color: green">; On Windows here</b> <br>== "C:\Users\Mike"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-pathxex"> get-path!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>A <a href="./index.html#get-pathxex">get-path!</a> is a kind of <a href="./index.html#pathxex">path!</a> used to access (get) a value. <br>Refer to <a href="./index.html#pathxex">path!</a> and <a href="./index.html#get-wordxex">get-word!</a> for more details.<br><br>To be completed by Red-by-example team.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Explore a get-path!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [11 22 33 44]<br><br>;with a variable<br>red>> place: 2<br>== 2<br>;use a get-path! Note preceding colon<br>red>> :b/:place<br>== 22<br>;Find the type - first [block] is used to prevent evaluation<br>red>> type? first [:b/:place]<br>== get-path!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-pathxqm"> get-path?</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#get-pathxqm">get-path?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#get-pathxex">get-path!</a>,<br>otherwise <a href="./index.html#false">false</a>.<br><br>Its single argument can be any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use get-path? on various types; must start with colon :</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [11 22 33]<br>== [11 22 33]<br><br>red>> n: 2<br>== 2<br><br>red>> get-path? b/n<br>== false<br><br>red>> get-path? first [:b/:n]<br>== true<br><br>red>> get-path? first [b/n]<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-wordxex"> get-word!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#get-wordxex">get-word!</a> is the way in which Red gets values from a variable.<br><br>The <a href="./index.html#get-wordxex">get-word!</a> type gets the value of a word (which is quite normal thus <br>far) but does not evaluate the value. For that we use a colon in front of <br>a variable.<br><br>For many simple data types, the result is the value. For special <a href="./index.html#datatypexex">datatype!</a>s<br>like functions, we need to use the get-word notation.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use <a href="./index.html#get-wordxex">get-word!</a> type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> w: 123<br>== 123<br><br>red>> w<br>== 123<br><br>red>> :w<br>== 123 <b style="color: green">; For normal variable same as evaluating it</b><br><br>red>> f: func [] [print "Hi!"]<br>== func [][print "Hi!"]<br><br>red>> f <b style="color: green">; Evaluate the function</b><br>Hi!<br><br>red>> :f <b style="color: green">; Use the get-word - retrieve the definition of f</b><br>== func [][print "Hi!"]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="get-wordxqm"> get-word?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>Returns true if its argument is a <a href="./index.html#get-wordxex">get-word!</a> type, otherwise false.<br><br>Its single argument can be of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A few types of argument</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-word: 123<br><br>;just a normal word<br>red>> get-word? a-word<br>== false<br>: :a-word syntax is correct, but word is evaluated<br>red>> get-word? :a-word<br>== false<br><br>;prevent evaluation, with first and a [block] <br>red>> get-word? first[:a-word]<br>== true<br><br>;this is a set-word!<br>red>> get-word? first[a-word:]<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="greater-or-equalxqm"> greater-or-equal?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#greater-or-equalxqm">greater-or-equal?</a> is the functional form of the <a href="./index.html#xgtxeq">>=</a><br>infix word.<br></pre>例子<pre>red>> greater-or-equal? 44 33<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="greaterxqm"> greater?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#greaterxqm">greater?</a> is the functional form of the <a href="./index.html#xgt">></a> infix word.<br></pre>例子<pre>red>> greater? 44 33<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="halt"> halt</span> type: function! Categories: <a href="./index.html#cat-e03">退出</a>, <a href="./index.html#cat-s05">系统相关</a><br><pre>The <a href="./index.html#halt">halt</a> word stops the interpretation of a script immediately.<br><br>Always returns a value of 1.<br></pre>例子<pre>fun1: func [p1] [<br> fun2 p1<br> print "fun2 completed"<br>]<br><br>fun2: func [p2] [<br> print "Before halt check ..."<br> if p2 = "halt" [halt]<br> print "After halt check"<br>]<br><br>fun1 "abc"<br><b style="color: blue">Before halt check ...</b><br><b style="color: blue">After halt check</b><br><b style="color: blue">fun2 completed</b><br><br>fun1 "halt"<br><b style="color: blue">Before halt check ...</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="has"> has</span> type: native! Categories: <a href="./index.html#cat-f03">函数</a><br><pre>关键字 <a href="./index.html#has">has</a> is a way to define a function that does have local variables <br>but has no arguments. <br><br>It is followed by a <a href="./index.html#blockxex">block!</a> of local variable names, and a <a href="./index.html#blockxex">block!</a> of code. <br></pre>例子<pre>calc-hours: has [number] [<br> number: 365 * 24 <b style="color: green">; number is local</b><br> print number<br>]<br>calc-hours<br><b style="color: blue">8760</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="hashxex"> hash!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#hashxex">hash!</a> provides a block-like interface but with fast <br>lookups for most values (block series can be stored in hash! too, but they <br>will not be hashed, so no faster access). <br><br>It is a very flexible container for any kind of hashed tables (not only <br>associative arrays) while keeping the handy navigational abilities of blocks. <br><br>A hash might save time with large data sets and repeated searching. <br><br>See also0 the <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#mapxex">map!</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a hash!, and use it</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> list: make hash! [a 123 "hello" b c 789]<br>== make hash! [a 123 "hello" b c 789]<br><br>red>> list/c<br>== 789<br><br>red>> find list 'b<br>== make hash! [b c 789]<br><br>red>> dict: make hash! [a 123 b 456 c 789]<br>== make hash! [a 123 b 456 c 789]<br><br>red>> select dict 'c<br>== 789<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Regard DICT as 2 records of size 3 and find value 456</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> select/skip dict 456 3<br>== 123<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="hashxqm"> hash?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>Returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#hashxex">hash!</a> type, otherwise <a href="./index.html#false">false</a>.<br><br>Arguments<br><br>One argument, of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; hash? with a hash! and a block!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> list: make hash! [a 123 "hello" b c 789]<br>;yes, a hash!<br>red>> hash? list<br>== true<br><br>;b is a block<br>red>> b: [1 2 3 4]<br>== [1 2 3 4]<br>red>> hash? b<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="head"> head</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#head">head</a> resets the index of a <a href="./index.html#seriesxex">series!</a> to its start.<br><br>Note that you can use the word <a href="./index.html#headxqm">head?</a> to test if a <a href="./index.html#seriesxex">series!</a> is at position 1.<br><br>Note that you can use the word <a href="./index.html#indexxqm">index?</a> to obtain the current index.<br><br></pre>例子<pre>red>> x: [1 2 3 4 5 6 7]<br>== [1 2 3 4 5 6 7]<br><br>red>> index? x<br>== 1<br><br>red>> head? x<br>== true<br><br>red>> x: skip x 3<br>== [4 5 6 7]<br><br>red>> index? x<br>== 4<br><br>red>> head? x<br>== false<br><br>red>> x: head x<br>== [1 2 3 4 5 6 7]<br><br>red>> index? x<br>== 1<br><br>red>> head? x<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="headxqm"> head?</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#headxqm">head?</a> checks whether a <a href="./index.html#seriesxex">series!</a> index is at the <a href="./index.html#head">head</a><br>position (= position 1) and returns <a href="./index.html#true">true</a> if it is at <a href="./index.html#head">head</a> or <a href="./index.html#false">false</a> <br>otherwise.<br><br>Note that you can use the word <a href="./index.html#indexxqm">index?</a> to obtain the current index!<br></pre>例子<pre>red>> x: [1 2 3]<br>== [1 2 3]<br><br>red>> head? x<br>== true<br><br>red>> index? x<br>== 1<br><br>red>> x: next x<br>== [2 3]<br><br>red>> head? x<br>== false<br><br>red>> index? x<br>== 2<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="help"> help</span> type: unset! Categories: <a href="./index.html#cat-d02">文档</a>, <a href="./index.html#cat-h01">帮助 & 调试</a><br><pre>The <a href="./index.html#help">help</a> word provides an overview of Red words and datatypes.<br>You may also type <a href="./index.html#xqm">?</a> instead of <a href="./index.html#help">help</a>.<br><br>Help has 1 argument:<br> - a Red <a href="./index.html#wordxex">word!</a>:<br> in this case <a href="./index.html#help">help</a> displays the help info for exactly that <a href="./index.html#wordxex">word!</a><br> - or a <a href="./index.html#stringxex">string!</a>:<br> in this case <a href="./index.html#help">help</a> displays every piece of help info where this<br> <a href="./index.html#stringxex">string!</a> occurs.<br></pre>例子<pre>red>> help add<br><b style="color: blue">USAGE:</b><br><b style="color: blue"> add value1 value2</b><br><br><b style="color: blue">DESCRIPTION:</b><br><b style="color: blue"> Returns the sum of the two values.</b><br><b style="color: blue"> add is of type: action!</b><br><br><b style="color: blue">ARGUMENTS:</b><br><b style="color: blue"> value1 [number! char! pair! tuple! vector!]</b><br><b style="color: blue"> value2 [number! char! pair! tuple! vector!]</b><br><br><b style="color: blue">REFINEMENTS:</b><br><br>red>> help *<br><b style="color: blue">USAGE:</b><br><b style="color: blue"> value1 * value2</b><br><br><b style="color: blue">DESCRIPTION:</b><br><b style="color: blue"> Returns the product of two values.</b><br><b style="color: blue"> * is of type: op!</b><br><br><b style="color: blue">ARGUMENTS:</b><br><b style="color: blue"> value1 [number! char! pair! tuple! vector!]</b><br><b style="color: blue"> value2 [number! char! pair! tuple! vector!]</b><br><br><b style="color: blue">REFINEMENTS:</b><br><br>red>> help native!<br><b style="color: blue"> all => Evaluates, returning at the first that is not true</b><br><b style="color: blue"> any => Evaluates, returning at the first that is true</b><br><b style="color: blue"> arccosine => Returns the trigonometric arccosine (in degrees by default)</b><br><b style="color: blue"> arcsine => Returns the trigonometric arcsine (in degrees by default)</b><br><b style="color: blue"> arctangent => Returns the trigonometric arctangent (in degrees by default)</b><br><b style="color: blue"> ... rest of output omitted here ...</b><br><br>red>> help "contr"<br><b style="color: blue"> continue => Throws control back to top of loop</b><br><b style="color: blue"> throw => Throws control back to a previous catch</b><br><br>red>> help "sine"<br><b style="color: blue"> acos => Returns the trigonometric arccosine</b><br><b style="color: blue"> arccosine => Returns the trigonometric arccosine (in degrees by default)</b><br><b style="color: blue"> arcsine => Returns the trigonometric arcsine (in degrees by default)</b><br><b style="color: blue"> asin => Returns the trigonometric arcsine</b><br><b style="color: blue"> cos => Returns the trigonometric cosine</b><br><b style="color: blue"> cosine => Returns the trigonometric cosine</b><br><b style="color: blue"> sin => Returns the trigonometric sine</b><br><b style="color: blue"> sine => Returns the trigonometric sine</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="if"> if</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a><br><pre>关键字 <a href="./index.html#if">if</a> evaluates a conditional expression. <br>If the result thereof is <a href="./index.html#true">true</a>, the <a href="./index.html#blockxex">block!</a> will be evaluated. <br>If <a href="./index.html#false">false</a> nothing happens.<br><br>Has 2 parameters:<br> 1. a conditional expression<br> 2. a <a href="./index.html#blockxex">block!</a>.<br><br>If returns the resulting value of the <a href="./index.html#blockxex">block!</a> if the condition is <a href="./index.html#true">true</a> and <br>else returns <a href="./index.html#none">none</a>.<br><br>Warning:<br> The <a href="./index.html#if">if</a> word is a pitfall for Red n00bs, because it doesn't have an <a href="./index.html#else">else</a> <a href="./index.html#blockxex">block!</a>.<br> The <a href="./index.html#either">either</a> word provides what programmers would expect.<br></pre>例子<pre>if 3 > 2 [print "3 > 2"]<br><b style="color: blue">3 > 2</b><br><br>if 3 > 2 [print "3 > 2"] [print "2 > 3"]<br><b style="color: blue">3 > 2</b><br>== [print "2 > 3"]<br><b style="color: green">; This is a n00b error.</b><br><b style="color: green">; The last block is not a part of the if, so the block is evaluated</b><br><b style="color: green">; as a stand-alone block, which returns the block itself!</b><br><br>if 2 = 2.0 [print "Different datatypes, but still equal!"]<br><b style="color: blue">Different datatypes, but still equal!</b><br><br>if 2 == 2.0 [print "Different datatypes NOT equal!"]<br><b style="color: blue">none</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="imagexex"> image!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="imagexqm"> image?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="in"> in</span> type: native! Categories: <a href="./index.html#cat-o01">对象</a><br><pre>关键字 <a href="./index.html#in">in</a> fetches a word from an object.<br><br>2 arguments:<br> 1. an <a href="./index.html#objectxex">object!</a> to be accessed<br> 2. the word to be fetched - a <a href="./index.html#wordxex">word!</a>, <a href="./index.html#blockxex">block!</a>, or <a href="./index.html#parenxex">paren!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use in on a-point</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-point: make object! [xval: 10 yval: 20]<br>== make object! [<br> xval: 10<br> yval: 20<br>]<br><br>red>> in a-point 'xval<br>== xval <b style="color: green">; Existing member of object</b><br><br>red>> in a-point 'xxval<br>== none <b style="color: green">; Not existing member of object</b>%<br><br>red>> get in a-point 'xval<br>== 10 <b style="color: green">; Value of member</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="indexxqm"> index?</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#indexxqm">index?</a> returns the current index of a <a href="./index.html#seriesxex">series!</a> relative to the head, <br>or of a word in a context. <br> <br>The argument can be:<br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#wordxex">word!</a><br><br>In Red, the name referring to a <a href="./index.html#seriesxex">series!</a> need not indicate the first item. <br>It can be moved to index any part of a series. <br>It is not like an array name in traditional languages.<br><br>NOTE: when you assign a variable to a series, that variable points to the same<br> series! as the one it is assigned to. This can cause big trouble!!!!<br> Normally always use <a href="./index.html#copy">copy</a> to avoid that.<br></pre>例子<pre><b style="color: green">; Create a series</b><br>red>> numbers: [2 4 8 3 9 27]<br>== [2 4 8 3 9 27]<br><br><b style="color: green">; Are we at the start of "numbers"? (index starts at 1, not zero)</b><br>red>> index? numbers<br>== 1<br><br><b style="color: green">; Find returns the part of the series! from the found item's position</b><br><b style="color: green">; or none if not found</b><br>red>> n: find numbers 9<br>== [9 27]<br><br><b style="color: green">; "n" is also a series!</b><br>red>> n<br>== [9 27]<br><br><b style="color: green">; But "n" still refers to the series! called "numbers"</b><br>red>> index? n<br>== 5<br><br><b style="color: green">; We could write this more concisely</b><br>red>> index? find numbers 9<br>== 5<br><br><b style="color: green">; Show that "n" is just a "pointer" into "numbers"</b><br><b style="color: green">; The "head"of "n" is the same as the "head" of "numbers"</b><br><b style="color: green">; because the underlaying series! is exactly the same!</b><br>red>> n: head n<br>== [2 4 8 3 9 27]<br><br><b style="color: green">; NOTE: beware that directly assigning to a series! can wreak havoc!</b><br>red>> s1: [1 2 3 4]<br>== [1 2 3 4]<br>red>> s2: next s1<br>== [2 3 4]<br>red>> append s2 5<br>== [1 2 3 4 5]<br><b style="color: green">; Append always returns the whole series! and does not consider the index</b><br>red>> s2<br>== [2 3 4 5]<br><b style="color: green">; "s2" is modified</b><br>red>> s1<br>= [1 2 3 4 5]<br><b style="color: green">; "s1" also modified!</b><br><br><b style="color: green">; NOTE: avoid this "problem" by using copy</b><br>red>> s1: [1 2 3 4]<br>== [1 2 3 4]<br>red>> s2: copy next s1<br>== [2 3 4]<br>red>> append s2 5<br>== [2 3 4 5]<br>red>> s2<br>== [2 3 4 5]<br><b style="color: green">; "s2"is modified</b><br>red>> s1<br>== [1 2 3 4]<br><b style="color: green">; But "s1" is left intact!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="input"> input</span> type: unset! Categories: <a href="./index.html#cat-i01">输入</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="insert"> insert</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#insert">insert</a> inserts (a) value(s) at a <a href="./index.html#seriesxex">series!</a> index. <br><br>The original <a href="./index.html#seriesxex">series!</a> is modified and insert returns the part of the <a href="./index.html#seriesxex">series!</a> <br>from the position following the <a href="./index.html#insert">insert</a>.<br><br>The 2 arguments are:<br> 1. a <a href="./index.html#seriesxex">series!</a> i.e <a href="./index.html#seriesxex bitsetxex mapxex">series! bitset! map!</a> <br> 2. a value, which can be of any type<br><br>Refinements:<br> /part - Limit the number of values inserted. <br> We provide a length of type: <a href="./index.html#numberxex">number!</a><br> or a "pointer" of type <a href="./index.html#seriesxex">series!</a><br> /only - <a href="./index.html#insert">insert</a> <a href="./index.html#blockxex">block!</a> types as single values (overrides /part).<br> Normally each value in a <a href="./index.html#blockxex">block!</a> would be separately inserted. <br> /dup - Duplicate the inserted values. Must provide a count of type <a href="./index.html#numberxex">number!</a><br> <br>NOTE: <a href="./index.html#insert">insert</a> is a destructive operation! It alters its argument.<br> Most of the time you need to <a href="./index.html#copy">copy</a> before using <a href="./index.html#insert">insert</a>!<br></pre>例子<pre>red>> s: "this is a string"<br>== "this is a string"<br><br><b style="color: green">; Insert at current index - which is 1.</b><br>red>> insert s "I think "<br>== "this is a string"<br>red>> s<br>== "I think this is a string"<br><br><b style="color: green">; Insert at other positions (e.g. after "d")</b><br>red>> letters: "abcdefg"<br>== "abcdefg"<br>red>> insert find letters "d" "XX"<br>== "defg"<br><b style="color: green">; This result is the result of "find", not of "insert"!</b><br>red>> letters<br>== "abcXXdefg"<br><b style="color: green">; Now you see the result of "insert".</b><br><br><b style="color: green">; Insert at the tail</b><br>red>> insert tail letters "-END-"<br>== ""<br><b style="color: green">; Again: this is the result of "find".</b><br>red>> letters<br>== "abcXXdefg-END-"<br><b style="color: green">; And this of "insert".</b><br><br><b style="color: green">; Insert a duplicate, 5 times</b><br>red>> insert/dup s "-" 5<br>== "I think this is a string"<br>red>> s<br>== "-----I think this is a string"<br><br><b style="color: green">; Make a string for /part</b><br>red>> s2: "YES it is"<br>== "YES it is"<br><b style="color: green">; Only insert the first 6 characters of "s2" into "s".</b><br>red>> insert/part s s2 6<br>== "-----I think this is a string"<br>red>> s<br>== "YES it-----I think this is a string"<br><br><b style="color: green">; We need a block type to illustrate /only.</b><br>red>> a-block: [3 4 5]<br>== [3 4 5]<br><b style="color: green">; Normal insert, without /only.</b><br>red>> insert a-block [33 44 55]<br>== [3 4 5]<br><b style="color: green">; Note the separate items.</b><br>red>> a-block<br>== [33 44 55 3 4 5]<br><br><b style="color: green">; Reset the block.</b><br>red>> a-block: [3 4 5]<br>== [3 4 5]<br><b style="color: green">; Now use /only</b><br>red>> insert/only a-block [33 44 55]<br>== [3 4 5]<br><b style="color: green">; Now the block is inserted, instead of its elements.</b><br>red>> a-block<br>== [[33 44 55] 3 4 5]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="integerxex"> integer!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#integerxex">integer!</a> represents a <a href="./index.html#numberxex">number!</a> type containing <br>32 bit whole signed numbers.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> 33 + 55<br>== 88<br><br>red>> 6 / 7<br>== 0 <b style="color: green">; Dividing 2 integers gives rounded result</b><br><br>red>> 6.0 / 7<br>== 0.8571428571428571<br><br>red>> add 6 7<br>== 13<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="integerxqm"> integer?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#integerxqm">integer?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#integerxex">integer!</a> type, <br>otherwise false.<br><br>Its argument can be any type.<br></pre>例子<pre><b style="color: green">; A literal integer value</b><br>red>> integer? 123<br>== true<br><br><b style="color: green">; A variable holding an integer value</b><br>red>> a: 456<br>== 456<br><br>red>> integer? a<br>== true<br><br>red>> integer? 22x30<br>== false<br><br>red>> integer? 12.3<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="intersect"> intersect</span> type: native! Categories: <a href="./index.html#cat-s02">集合</a><br><pre>关键字 <a href="./index.html#intersect">intersect</a> returns the intersection (the common items) of two sets. <br><br>The arguments can be sets of:<br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#hashxex">hash!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a><br><br>To create a set with no duplicate items, the <a href="./index.html#unique">unique</a> function can be used.<br><br>Refinements:<br> /case - use case-sensitive comparison.<br> /skip - treat the <a href="./index.html#seriesxex">series!</a> as fixed size records. <br> The specified size is an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre><b style="color: green">; Create 2 series</b><br>red>> list1: ["India" "China" "Vietnam" "Singapore"]<br>== ["India" "China" "Vietnam" "Singapore"]<br><br>red>> list2: ["uk" "china" "USA" "India" "France"]<br>== ["uk" "china" "USA" "India" "France"]<br><br><b style="color: green">; Common values in these sets</b><br>red>> intersect list1 list2<br>== ["India" "China"]<br><br><b style="color: green">; When case sensitive</b><br>red>> intersect/case list1 list2<br>== ["India"]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="is"> is</span> type: op! Categories: <a href="./index.html#cat-is">none</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="issuexex"> issue!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="issuexqm"> issue?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="keys-of"> keys-of</span> type: function! Categories: <a href="./index.html#cat-f03">函数</a>, <a href="./index.html#cat-r01">反射</a><br><pre>Theword <a href="./index.html#keys-of">keys-of</a> returns the list of words of a value that supports reflection. <br><br>Arguments<br> One argument, which should support reflection, e.g. <a href="./index.html#mapxex">map!</a>, <a href="./index.html#objectxex">object!</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Extract the keys of an object</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-point: make object! [<br>[ xval: 10<br>[ yval: 20<br>[ ]<br>== make object! [<br> xval: 10<br> yval: 20<br>]<br><br>red>> keys-of a-point<br>== [xval yval]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Extract the keys of a map</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-map: make map![height 6.1 weight 250 age 45]<br>== #(<br> height: 6.1<br> weight: 250<br> age: 45<br>)<br><br>red>> keys-of a-map<br>== [height weight age]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="last"> last</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#last">last</a> returns the last value in a <a href="./index.html#seriesxex">series!</a>. <br>If the <a href="./index.html#seriesxex">series!</a> is empty, <a href="./index.html#none">none</a> is returned.<br><br>Its single argument is a <a href="./index.html#seriesxex">series!</a>. <br>Note that a <a href="./index.html#stringxex">string!</a> is a series of <a href="./index.html#charxex">char!</a>.<br></pre>例子<pre>red>> last ["cat" "dog" "bird"]<br>== "bird"<br><br>red>> last [33 44]<br>== 44<br><br>red>> last []<br>== none<br><br>red>> last "abcd"<br>== #"d"<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="last-lfxqm"> last-lf?</span> type: routine! Categories: <a href="./index.html#cat-i01">输入</a>, <a href="./index.html#cat-o02">输出</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="layout"> layout</span> type: unset! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="lengthxqm"> length?</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#lengthxqm">length?</a> returns the number of values in a <a href="./index.html#seriesxex">series!</a>, <br>from the current index to the tail. <br><br>The length of an empty <a href="./index.html#seriesxex">series!</a> is 0.<br><br>The length of none is none.<br><br>Its single argument can be one of these types: <br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#mapxex">map!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#none">none</a><br></pre>例子<pre>red>> length? [10 20 30]<br>== 3<br><br>red>> length? []<br>== 0<br><br><b style="color: green">; Tuple</b><br>red>> length? 22.33.44.100<br>== 4<br><br><b style="color: green">; Find returns the series from the found item (30) onwards,</b><br><b style="color: green">; which is [30 40 50]</b><br>red>> length? find [10 20 30 40 50] 30<br>== 3<br><br>red>> length? none<br>== none<br><br><b style="color: green">; Find returns none; then length is none.</b><br>red>> length? find [10 20 30 40 50] 123<br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="lesser-or-equalxqm"> lesser-or-equal?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#lesser-or-equalxqm">lesser-or-equal?</a> returns <a href="./index.html#true">true</a> if the first argument<br>is less than or equal to the second argument, otherwise <a href="./index.html#false">false</a>. <br><br>It is the functional equivalent of the infix word <a href="./index.html#xltxeq"><=</a>.<br></pre>例子<pre>red>> lesser-or-equal? 33 44<br>== true<br><br>red>> "ABC" <= "abc"<br>== true<br><br>red>> "abc" <= "ABC"<br>== true<br><br>red>> [4 8 5] <= [4 2 1]<br>== false<br><br>red>> [4 1 1] <= [4 2 1]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="lesserxqm"> lesser?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#lesserxqm">lesser?</a> returns <a href="./index.html#true">true</a> if the first argumjent is <br>less than the second argument, otherwise <a href="./index.html#false">false</a>. <br><br>It is the functional equivalent of the infix word <a href="./index.html#xlt"><</a>.<br></pre>例子<pre>red>> lesser? 33 44<br>== true<br><br>red>> lesser? [8 5 2] [ 7 5 2]<br>== false<br><br>red>> lesser? [6 5 2] [ 7 5 2]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="list-dir"> list-dir</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#list-dir">list-dir</a> shows a list of all files and directories within the<br>directory given as its argument.<br><br>Refinements:<br> /col - displays in n columns instead of the default 4<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show contents of current directory</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> list-dir %/e/src<br> 8th/ go/ python/ red/<br> spiderbasic/ <br><br>red>> list-dir/col %/e/src 3<br> 8th/ go/ python/ <br> red/ spiderbasic/ <br>red>> list-dir/col %/e/src 2<br> 8th/ go/ <br> python/ red/ <br> spiderbasic/ <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="list-env"> list-env</span> type: native! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>关键字 <a href="./index.html#list-env">list-env</a> returns a <a href="./index.html#mapxex">map!</a> of OS environment variables/values<br>of the current process. <br><br>No arguments. <br><br>To get the value of a specific variable, use <a href="./index.html#get-env">get-env</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use list-env on a Windows PC</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> type? list-env<br>== map!<br><br>red>> list-env<br>== #(<br> "=::" "::\"<br> "=E:" "E:\Websites\Red-by-Example\auto-v5"<br> "ALLUSERSPROFILE" "C:\ProgramData"<br> "APPDATA" "C:\Users\xapwi\AppData\Roaming"<br> "CommonP... <b style="color: green">; The three dots indicate that more ouput is skipped</b><br> <br>red>> print list-env <b style="color: green">; Prints all the output</b><br>... <b style="color: green">; Output suppressed - too big</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="lit-pathxex"> lit-path!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="lit-pathxqm"> lit-path?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="lit-wordxex"> lit-word!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#lit-wordxex">lit-word!</a> is needed to get the literal value (the name) <br>of a word. <br><br>To get the lit-word of variable w, we use 'w.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a lit-word type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-word: 123<br>== 123<br><br>red>> a-word<br>== 123<br><br>red>> 'a-word<br>== a-word<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="lit-wordxqm"> lit-word?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>Returns true if its argument is a <a href="./index.html#lit-wordxex">lit-word!</a> type, otherwise false.<br><br>Its single argument can be of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A few types of argument</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> a-word: 123<br><br>red>> lit-word? a-word<br>== false<br><br>;correct lit-word syntax, but we should not evaluate it<br>red>> lit-word? 'a-word<br>== false<br><br>;prevent evaluation with first [block] <br>red>> lit-word? first ['a-word]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="ll"> ll</span> type: unset! Categories: <a href="./index.html#cat-dir">none</a>, <a href="./index.html#cat-f01">文件</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="load"> load</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-i01">输入</a><br><pre>关键字 <a href="./index.html#load">load</a> returns a value or <a href="./index.html#blockxex">block!</a> of values from a file. <br><br>Text files and certain types of binary files can be handled.<br><br>Its argument specifies the <a href="./index.html#pathxex">path!</a> to the data and can be:<br> <a href="./index.html#filexex">file!</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#binaryxex">binary!</a><br><br>Refinements:<br> /part - load a part of the data, where the part length is <br> <a href="./index.html#integerxex">integer!</a> or <a href="./index.html#stringxex">string!</a><br> /into - put results into an existing <a href="./index.html#blockxex">block!</a>, instead <br> of creating a new <a href="./index.html#blockxex">block!</a>. <br> We need then to provide a <a href="./index.html#blockxex">block!</a> to be used.<br> /as - specify the type of the data to be loaded; <br> we need to specify either:<br> - none -> load data as code<br> - word! -> e.g. json, html, jpeg, png, etc.<br> /header - include Red header as a loaded value<br> /all - does not evaluate Red header<br></pre>例子<pre><b style="color: green">; one-number.txt has one number in it.</b><br>red>> load %one-number.txt<br>== 234<br><br><b style="color: green">; This file has 3 numbers, one per line.</b><br><b style="color: green">; For more than 1 item, a block will be created.</b><br>red>> load %three-numbers.txt<br>== [234 567 789]<br><br><b style="color: green">; Store the result of load.</b><br>red>> some-numbers: load %three-numbers.txt<br>== [234 567 789]<br><br>red>> some-numbers<br>== [234 567 789]<br><br>red>> genres: load %music-types.txt<br>== ["Blues" "Rock" "Jazz"]<br><br><b style="color: green">; It is easy to put program code in a file</b><br><b style="color: green">; and load it ...</b><br>red>> prog: load %code-type.txt<br>== [print "Hello from a block of code in a file!"]<br><br><b style="color: green">; Use do to execute the result of a load.</b><br>red>> do prog<br>Hello from a block of code in a file!<br><br><b style="color: green">; face.jpg contains an image, 216 x 216 pixels.</b><br><b style="color: green">; (the console truncates long values to ... )</b><br>red>> p: load %face.jpg<br>== make image! [216x216 #{<br>AFB3B6AFB3B6AFB3B6AFB3B6AEB2B5AEB2B5AEB...<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="log-10"> log-10</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#log-10">log-10</a> returns the logarithm (base 10) of its argument.<br><br>The argument can be a <a href="./index.html#numberxex">number!</a> (a <a href="./index.html#floatxex">float!</a> or an <a href="./index.html#integerxex">integer!</a> )<br></pre>例子<pre>red>> log-10 9.9<br>== 0.99563519459755<br><br>red>> log-10 1000<br>== 3.0 <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="log-2"> log-2</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#log-2">log-2</a> returns the logarithm (base 2) of its argument.<br><br>The argument can be a <a href="./index.html#numberxex">number!</a> (a <a href="./index.html#floatxex">float!</a> or an <a href="./index.html#integerxex">integer!</a>)<br></pre>例子<pre>red>> log-2 2.1<br>== 1.070389327891398<br><br>red>> log-2 32<br>== 5.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="log-e"> log-e</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#log-e">log-e</a> returns the natural (base E) logarithm of its argument.<br><br>The argument can be a <a href="./index.html#numberxex">number!</a> (a <a href="./index.html#floatxex">float!</a> or an <a href="./index.html#integerxex">integer!</a>)<br></pre>例子<pre>red>> log-e 2.7<br>== 0.9932517730102835<br><br>red>> log-e 3<br>== 1.09861228866811<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="logicxex"> logic!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#logicxex">logic!</a> consists of two states representing <br><a href="./index.html#true">true</a> and <a href="./index.html#false">false</a>. <br><br>They are returned from comparisons using <a href="./index.html#xgt">></a> <a href="./index.html#xltxeq"><=</a> etc.<br><br>The provided boolean words and their values are: <br><br> - the pair:<br> <a href="./index.html#true">true</a> = <a href="./index.html#true">true</a><br> <a href="./index.html#false">false</a> = <a href="./index.html#false">false</a><br><br> - the pair:<br> <a href="./index.html#on">on</a> = <a href="./index.html#true">true</a><br> <a href="./index.html#off">off</a> = <a href="./index.html#false">false</a><br><br> - the pair:<br> <a href="./index.html#yes">yes</a> = <a href="./index.html#true">true</a><br> <a href="./index.html#no">no</a> = <a href="./index.html#false">false</a><br><br>Note that <a href="./index.html#on">on</a> and <a href="./index.html#off">off</a> and <a href="./index.html#yes">yes</a> and <a href="./index.html#no">no</a> have no built-in logic. <br>They are preset words which can be more meaningful in certain situations.<br>.pre <br>red>> 3 > 2<br>== true<br><br>red>> a: 3<br>== 3<br><br>red>> answer: a > 2<br>== true<br><br>red>> answer<br>== true<br><br>red>> not answer<br>== false<br><br>red>> if a > 2 [print "bigger"]<br>bigger<br><br>red>> yes<br>== true<br><br><b style="color: green">; Note: we get <a href="./index.html#false">false</a>, not <a href="./index.html#no">no</a></b><br>red>> not yes<br>== false<br><br>red>> power-switch: off<br>== false<br> <br>red>> if power-switch = off [power-switch: on]<br>== true<br><br><b style="color: green">; Note, not <a href="./index.html#on">on</a> but <a href="./index.html#true">true</a>.</b><br>red>> power-switch<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="logicxqm"> logic?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#logicxqm">logic?</a> returns <a href="./index.html#true">true</a> if its argument is of <br>the <a href="./index.html#logicxex">logic!</a> <a href="./index.html#datatypexex">datatype!</a>, otherwise <a href="./index.html#false">false</a>.<br><br>its argument can be on any type.<br></pre>例子<pre>red>> open: true<br>== true<br><br>red>> logic? open<br>== true<br><br>red>> large: false<br>== false<br><br><b style="color: green">; It is true that 'false' is a logic! type.</b><br>red>> logic? large<br>== true<br><br><b style="color: green">; Expressions resulting in a <a href="./index.html#logicxex">logic!</a> result</b><br>red>> logic? 3 > 2<br>== true<br><br>red>> logic? 3 + 2<br>== false<br><br><b style="color: green">; <a href="./index.html#yes">yes</a>, <a href="./index.html#no">no</a>, <a href="./index.html#on">on</a> and <a href="./index.html#off">off</a> are also <a href="./index.html#logicxex">logic!</a></b><br>red>> logic? yes<br>== true<br><br>red>> logic? no<br>== true<br><br>red>> logic? on<br>== true<br><br>red>> logic? off<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="loop"> loop</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#loop">loop</a> executes a given <a href="./index.html#blockxex">block!</a> a given number of times.<br><br>Has 2 parameters:<br> 1. a <a href="./index.html#numberxex">number!</a> (number of times to evaluate the <a href="./index.html#blockxex">block!</a>)<br> 2. a <a href="./index.html#blockxex">block!</a> (to be evaluated the specified number of times)<br><br><a href="./index.html#loop">loop</a> has no return value.<br></pre>例子<pre>loop 3 [print "Hi!"]<br><b style="color: blue">Hi!</b><br><b style="color: blue">Hi!</b><br><b style="color: blue">Hi!</b><br><br>i: 0<br>loop 10 [i: i + 1]<br>print ["Value of i =" i]<br><b style="color: blue">Value of i = 10</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="lowercase"> lowercase</span> type: native! Categories: <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#lowercase">lowercase</a> converts a string of characters to lower-case. <br> <br>The single argument can be a <a href="./index.html#stringxex">string!</a> or a <a href="./index.html#charxex">char!</a>.<br><br>Refinements:<br> /part - limits to a given length or position.<br><br>NOTE: this is a destructive operation. When applying it to a variable,<br> the variable will be changed!<br> <br>See also <a href="./index.html#uppercase">uppercase</a>. <br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try lowercase on char and string</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> lowercase #"A"<br>== #"a"<br><br>red>> lowercase "ABCD EFGH ijk"<br>== "abcd efgh ijk"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use /part to specify first 2 chars only</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> lowercase/part "ABCD EFGH ijk" 2<br>== "abCD EFGH ijk"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="ls"> ls</span> type: unset! <pre>This word is a synonym for <a href="./index.html#list-dir">list-dir</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="make"> make</span> type: action! Categories: <a href="./index.html#cat-c06">创建</a>, <a href="./index.html#cat-d03">数据类型</a><br><pre>关键字 <a href="./index.html#make">make</a> returns a new value, based on a type and a specification for the type.<br><br>It has 2 arguments:<br> 1. the <a href="./index.html#datatypexex">datatype!</a>, an example or a prototype value<br> 2. the specification of the new value or the number of items (for <a href="./index.html#vectorxex">vector!</a>).<br><br>The actual detail of these arguments depends on the <a href="./index.html#datatypexex">datatype!</a>.<br><br>For <a href="./index.html#seriesxex">series!</a> types, the specification is often a value for the initial size<br>of the <a href="./index.html#seriesxex">series!</a>.<br></pre>例子<pre>red>> make block! 10 ;; size 10 initially<br>== []<br><br>red>> make [] 3<br>== []<br><br>red>> make vector! [1 5 3]<br>== make vector! [1 5 3]<br><br>red>> make vector! 6<br>== make vector! [0 0 0 0 0 0]<br><br>v: make vector! 0<br>== make vector! []<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="make-dir"> make-dir</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>关键字 <a href="./index.html#make-dir">make-dir</a> creates a directory. <br><br>Returns no error if the directory already exists; the contents of existing <br>directories will be preserved.<br><br>The single argument is a <a href="./index.html#filexex">file!</a>.<br><br>Refinements<br> /deep - create subdirectories as well<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Make directory in the directory that the interpreter was run from</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> make-dir %make2/<br>== %make2/<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /deep refinement - new directory make3, and its sub-dir</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> make-dir/deep %make3/sub-dir/<br>== %make3/sub-dir/<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="mapxex"> map!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#mapxex">map!</a> represents a <a href="./index.html#seriesxex">series!</a> type.<br><br>This datatype provides a dictionary-like data structure, to make it <br>easy to store key/value pairs while providing very fast lookups. <br><br>Note that a <a href="./index.html#mapxex">map!</a> is NOT a <a href="./index.html#seriesxex">series!</a>, so does not have the <br>concept of offset or positions.<br><br>A <a href="./index.html#mapxex">map!</a> can have a wide range of types for its keys and values.<br><br>Entering a <a href="./index.html#mapxex">map!</a> in literal format:<br> #(key1: val1 key2: val2 ... key3: val3)<br> <br>Note that select and put are case-insensitive about keys. <br> To make them case-sensitive, use the case refinement, as in select/case.<br>.pre <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create 2 users with their respective passwords in a <a href="./index.html#mapxex">map!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> users: make map! ["John23" "safe3" "DingSnooker" "mypasswd"]<br>== #(<br> "John23" "safe3"<br> "DingSnooker" "mypasswd"<br>)<br><br>red>> print users<br><b style="color: blue">"John23" "safe3"</b><br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Retrieve passwords</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print select users "john23" <b style="color: green">; Note: case insensitive!</b><br><b style="color: blue">safe3</b><br><br>red>> print select users "mr-x"<br><b style="color: blue">none</b> <b style="color: green">; Not found in the <a href="./index.html#mapxex">map!</a></b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add a new user/password</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> put users "JaneUK" "magicpass"<br>== "magicpass"<br><br>red>> print users<br><b style="color: blue">"John23" "safe3"</b><br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><b style="color: blue">"JaneUK" "magicpass"</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Change a password for an existing user</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> put users "John23" "mygoodPass"<br>== "mygoodPass"<br><br>red>> print users<br><b style="color: blue">"John23" "mygoodPass"</b><br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><b style="color: blue">"JaneUK" "magicpass"</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Delete a user</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> put users "John23" none<br>== none<br><br>red>> print users<br><b style="color: blue">"DingSnooker" "mypasswd"</b><br><b style="color: blue">"JaneUK" "magicpass"</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; How many users left?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print length? users<br><b style="color: blue">2</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Select a user by his key</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> users: make map! ["John23" "safe3" "DingSnooker" "mypasswd"]<br>== #(<br> "John23" "safe3"<br> "DingSnooker" "mypasswd"<br>)<br>red>> select users "John23"<br>== "safe3"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="mapxqm"> map?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#mapxqm">map?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#mapxex">map!</a> <a href="./index.html#datatypexex">datatype!</a>, <br>otherwise false.<br><br>This <a href="./index.html#datatypexex">datatype!</a> provides a dictionary-like data structure, <br>storing key/value pairs.<br></pre>例子<pre><b style="color: green">; Using a map literal</b><br>red>> p: #(a: 3 b: 4 c: 5)<br>== #(<br> a: 3<br> b: 4<br> c: 5<br>)<br><br><b style="color: green">; Use <a href="./index.html#make">make</a> to create a map</b><br>red>> users: make map! ["John23" "safe3" "DingSnooker" "mypasswd"]<br>== #(<br> "John23" "safe3"<br> "DingSnooker" "mypasswd"<br>)<br><br>red>> map? users<br>== true<br><br>red>> ages: [1 1949 2 1980 3 1999]<br>== [1 1949 2 1980 3 1999]<br><br>red>> map? ages<br>== false<br><br><b style="color: green">; Extending a map with new keys/values:</b><br>red>> x: make map! [1 "January" 2 "Februari" 3 "March"]<br>== #(<br> 1 "January"<br> 2 "Februari"<br> 3 "March"<br>)<br><br>red>> extend x [4 "April" 5 "May"]<br>== #(<br> 1 "January"<br> 2 "Februari"<br> 3 "March"<br> 4 "April"...<br> <br>red>> print mold x<br>#(<br> 1 "January"<br> 2 "Februari"<br> 3 "March"<br> 4 "April"<br> 5 "May"<br>)<br><br><b style="color: green">; Retrieving a value using a key.</b><br>red>> x/1<br>== "January"<br><br>red>> x/5<br>== "May"<br><br><b style="color: green">; Out of range</b><br>red>> x/7<br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="math"> math</span> type: unset! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>This function evaluates a <a href="./index.html#blockxex">block!</a> using mathematical precedence rules, <br>returning the last result. <br><br>Arguments<br><br>The single argument is a <a href="./index.html#blockxex">block!</a>.<br><br></pre>例子<pre>. box Evaluate a block with math, then without.<br>>> a: 6<br>== 6<br>; Evaluate the / before the +<br>>> math [a + 8 / 2]<br>== 10<br><br>; Now left-to right, the + first<br>>> print [a + 8 / 2]<br>7<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="max"> max</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#max">max</a> returns the greater of its 2 arguments. <br><br>The 2 arguments must be of: <br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#charxex">char!</a><br></pre>例子<pre>red>> max 4 3<br>== 4<br><br>red>> max 3.1 3.11<br>== 3.11<br><br>red>> max #"B" #"C"<br>== #"C"<br><br>red>> max "ABC" "BBC"<br>== "BBC"<br><br>red>> max "ABC" "ABCD"<br>== "ABCD"<br><br>red>> max [1 2 3] [2 2 3 3]<br>== [2 2 3 3]<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="min"> min</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#min">min</a> returns the smaller of its two arguments. <br><br>There are 2 arguments of type: <br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#charxex">char!</a><br></pre>例子<pre>red>> min 4 3<br>== 3<br><br>red>> min 3.1 3<br>== 3<br><br>red>> min #"B" #"C"<br>== #"B"<br><br>red>> min "ABC" "BBC"<br>== "ABC"<br><br>red>> min "ABC" "ABCD"<br>== "ABC"<br><br>red>> min [1 2 3] [3 2 1 0]<br>== [1 2 3]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="modify"> modify</span> type: action! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="modulo"> modulo</span> type: function! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#modulo">modulo</a> computes the non-negative <a href="./index.html#remainder">remainder</a> of the <br>first argument divided by the second argument.<br><br>The arguments can be of type: <br> <a href="./index.html#numberxex">number!</a><br></pre>例子<pre><b style="color: green">; 7 divides 2 times, remainder 1</b><br>red>> modulo 15 7<br>== 1<br><br><b style="color: green">; 2 divides 2 times, remainder 0.4</b><br>red>> modulo 6.4 2<br>== 0.4000000000000004<br><br><b style="color: green">; 7 divides -3 times, remainder +6</b><br>red>> modulo -15 7<br>== 6<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="mold"> mold</span> type: action! Categories: <a href="./index.html#cat-f02">格式化</a><br><pre>关键字 <a href="./index.html#mold">mold</a> returns a Red-readable <a href="./index.html#stringxex">string!</a> representing a value.<br><br>This means that, for example, values can be stored in files and re-input to<br>a program when <a href="./index.html#mold">mold</a>ed.<br><br>Type information is included in the <a href="./index.html#stringxex">string!</a>for example:<br> [ ] around a block,<br> #"" around a character<br> and { } around multi-line strings<br><br>A single argument of any type is required<br><br>Refinements<br> /only - Exclude outer brackets if value is a <a href="./index.html#blockxex">block!</a><br> /all - Return value in loadable format<br> /flat - Exclude all indentation<br> /part - Limit the length of the result, where limit is an <a href="./index.html#integerxex">integer!</a><br></pre>例子<pre>red>> print mold 12.34<br><b style="color: blue">12.34</b><br><br>red>> print mold "a string"<br><b style="color: blue">"a string"</b><br><br>red>> mold #"A"<br>#"A"<br><br>red>> print mold { The Great<br> Wall Of<br> China}<br><b style="color: blue">" The Great^/ Wall Of^/China"</b><br><br>red>> print mold [1 2 3]<br><b style="color: blue">[1 2 3]</b><br><br>red>> print mold/only [1 2 3]<br><b style="color: blue">1 2 3</b><br><br>red>> print mold/part [1 2 3 4 5] 3<br><b style="color: blue">[1</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="move"> move</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>Moves one or more elements from one series to another position or series. <br>By default, one element is moved. The origin series is modified and <br>returned. The target series is modified. <br><br>Arguments<br><br> origin - a <a href="./index.html#seriesxex">series!</a><br> target - a <a href="./index.html#seriesxex">series!</a><br><br>Refinements<br> /part - control the number of values inserted. We supply an <br> <a href="./index.html#integerxex">integer!</a> length.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; move, and its effects</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;make 2 series<br>red>> s1: [a b c d]<br>red>> s2: [11 12]<br><br>;move first element of s1 to s2<br>;note the returned value: a modified s1<br>red>> move s1 s2<br>== [b c d]<br><br>;s1 is modified<br>red>> s1<br>== [b c d]<br><br>;s2 is modified<br>red>> s2<br>== [a 11 12]<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /part refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;make 2 series<br>red>> s1: [a b c d e]<br>red>> s2: [1 2 3 4]<br><br>;move 2 elements, not 1<br>red>> move/part s1 s2 2<br>== [c d]<br>red>> s2<br>== [a b 1 2 3 4]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="multiply"> multiply</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#multiply">multiply</a> multiplies 2 <a href="./index.html#numberxex">number!</a>s.<br>This is equivalent to the infix operator <a href="./index.html#xmu">*</a>.<br><br>Has 2 arguments, which must be of type:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br></pre>例子<pre>red>> multiply 3 4.2<br>== 12.6<br><br>red>> multiply 11x20 4<br>== 44x80<br><br>red>> multiply 1.4.5 2<br>== 2.8.10<br><br>red>> v: make vector![2 3 4]<br>== make vector! [2 3 4]<br><br>red>> v2: make vector![20 20 3]<br>== make vector! [20 20 3]<br><br>red>> multiply v v2<br>== make vector! [40 60 12]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="NaN"> NaN</span> type: unset! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="NaNxqm"> NaN?</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#NaNxqm">NaN?</a> returns <a href="./index.html#true">true</a> if the argument is 'not a number',<br>otherwise <a href="./index.html#false">false</a>.<br><br>'Not a number' means that it is impossible to represent it internally.<br><br>The argument is of type: <a href="./index.html#numberxex">number!</a><br></pre>例子<pre><b style="color: green">; 1.5 is a valid <a href="./index.html#numberxex">number!</a></b><br>red>> NaN? 3 / 2<br>== false<br><br><b style="color: green">; 3 is a valid <a href="./index.html#numberxex">number!</a></b><br>red>> NaN? square-root 9<br>== false<br><br><b style="color: green">; Square root of a negative number.</b><br>red>> NaN? square-root -9<br>== true<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="nativexex"> native!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="nativexqm"> native?</span> type: function! Categories: <a href="./index.html#cat-f03">函数</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="negate"> negate</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#negate">negate</a> inverses its argument (positive <-> negative).<br></pre>例子<pre>red>> negate 3<br>== -3<br><br>red>> negate -3<br>== 3<br><br>red>> negate 5x4<br>== -5x-4<br><br>red>> negate 5x-4<br>== -5x4<br><br>red>> negate -5x4<br>== 5x-4<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="negativexqm"> negative?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#negativexqm">negative?</a> returns <a href="./index.html#true">true</a> if the numeric parameter <br>is less than zero, otherwise <a href="./index.html#false">false</a>.<br><br>NOTE that zero returns <a href="./index.html#false">false</a>.<br><br>Has one numeric parameter.<br></pre>例子<pre>negative? -2<br>== true<br><br>negative? 0<br>== false<br><br>negative? 0.1<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="new-line"> new-line</span> type: native! Categories: <a href="./index.html#cat-c05">常量</a>, <a href="./index.html#cat-o02">输出</a><br><pre>word <a href="./index.html#new-line">new-line</a> sets or clears the new-line markers within a <a href="./index.html#blockxex">block!</a> or <a href="./index.html#parenxex">paren!</a>. <br>These markers are not considered when Red examines values, but do affect the displayed <br>format. The original <a href="./index.html#seriesxex">series!</a> is modified.<br><br>Arguments<br> 1. position - a <a href="./index.html#blockxex">block!</a> or <a href="./index.html#parenxex">paren!</a>, positioned to the required place.<br> 2. value - <a href="./index.html#logicxex">logic!</a>. Use <a href="./index.html#true">true</a>/<a href="./index.html#on">on</a>/<a href="./index.html#yes">yes</a> for newlines to be added.<br><br>Refinements<br> /all - set/clear marker to end of series.<br> /skip - set/clear marker periodically to the end of the series. <br> We must provide and <a href="./index.html#integerxex">integer!</a> skip size.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show that series can contain new-lines</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b1: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6] <b style="color: green">; No new-lines here</b><br><br>red>> b2:[ 1 2 <b style="color: green">; First new-line in series</b><br>[ 3 4 <b style="color: green">; Second new-line in series</b><br>[ 5 6]<br>== [1 2 <br> 3 4 <br> 5 6<br>]<br><br>red>> b2<br>== [1 2 <br> 3 4 <br> 5 6<br>]<br><br>red>> b1 = b2<br>== true <b style="color: green">; Equal despite new-lines difference</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Manipulate series with new-lines</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6]<br><br>red>> new-line next next b on<br>== [<br> 3 4 5 6 <b style="color: green">; Returns the series beginning with the new new-line</b><br>]<br>red>> b<br>== [1 2 <b style="color: green">; Now the new-line becomes visible</b><br> 3 4 5 6<br>]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /all refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> new-line/all b off<br>== [1 2 3 4 5 6] <b style="color: green">; All new-lines removed</b><br><br>red>> new-line/all b on<br>== [ <b style="color: green">; Now new-lines everywhere</b><br> 1 <br> 2 <br> 3 <br> 4 <br> 5 <br> 6<br>]<br><br>red>> new-line/all b off<br>== [1 2 3 4 5 6] <b style="color: green">; All new-lines removed</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; The /skip refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> new-line/all/skip b on 2<br>== [<br> 1 2 <br> 3 4 <br> 5 6<br>]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="new-linexqm"> new-line?</span> type: native! Categories: <a href="./index.html#cat-o02">输出</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="next"> next</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#next">next</a> moves the index of a <a href="./index.html#seriesxex">series!</a> 1 position towards<br>the <a href="./index.html#tail">tail</a> (= the end) of the <a href="./index.html#seriesxex">series!</a>.<br><br>When a <a href="./index.html#seriesxex">series!</a> index is already at <a href="./index.html#tail">tail</a> position, <a href="./index.html#next">next</a> won't<br>change the index; it stays at <a href="./index.html#tail">tail</a>.<br><br>The opposite of <a href="./index.html#next">next</a> is <a href="./index.html#back">back</a>.<br></pre>例子<pre>red>> ser: [1 2 3]<br>== [1 2 3]<br><br>red>> ser: [1 2 3]<br>== [1 2 3]<br><br>red>> next ser<br>== [2 3]<br><br>red>> ser <b style="color: green">; <a href="./index.html#next">next</a> is not destructive</b><br>== [1 2 3]<br><br>red>> ser: next ser<br>== [2 3]<br><br>red>> ser<br>== [2 3]<br><br>red>> ser: next ser<br>== [3]<br><br>red>> ser<br>== [3]<br><br>red>> ser: next ser<br>== [] <b style="color: green">; We are at <a href="./index.html#tail">tail</a> postion</b><br><br>red>> tail? ser<br>== true<br><br>red>> ser<br>== []<br><br>red>> ser: next ser <b style="color: green">; Already at <a href="./index.html#tail">tail</a> - do nothing</b><br>== []<br><br>red>> tail? ser<br>== true<br><br>red>> ser<br>== []<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="no"> no</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>The value <a href="./index.html#no">no</a> can be used as the boolean value <a href="./index.html#false">false</a>.<br></pre>例子<pre>red>> no<br>== false<br><br>red>> not no<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="none"> none</span> type: none! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>关键字 <a href="./index.html#none">none</a> is a special value, and its datatype is <a href="./index.html#nonexex">none!</a><br><br><a href="./index.html#none">none</a> is not the same as an empty <a href="./index.html#blockxex">block!</a>, empty <a href="./index.html#stringxex">string!</a>, <br>zero <a href="./index.html#numberxex">number!</a> or null <a href="./index.html#charxex">char!</a>.<br><br>It is an actual value that represents non-existence.<br><br><a href="./index.html#none">none</a> is returned in certain circumstances from several functions,<br>primarily those involving <a href="./index.html#seriesxex">series!</a>.<br></pre>例子<pre>pick [11 22 33] 2<br>== 22<br><b style="color: green">; Elements in a block are numbered 1 thru n</b><br><br>pick [11 22 33] 4<br>== none<br><b style="color: green">; Out of range results in a none value</b><br><br>pick [true false true] 2<br>== false<br><br>pick [true false true] 4<br>== none<br><b style="color: green">; Out of range results in a none value</b><br><br>a: 123<br>== 123<br><br>type? a<br>== integer!<br><br>a: none<br>== none<br><b style="color: green">; none is just a value, like 123 before</b><br><br>type? a<br>== none!<br><br>either pick [11 22 33] 4 [print "got it"] [print "problem"]<br><b style="color: blue">problem</b><br><b style="color: green">; In a comparison none behaves the same as false</b><br><br>some-function: func [arg1] [<br> <b style="color: green">; code omitted</b><br> return none <b style="color: green">; no answer found</b><br>]<br><b style="color: green">; This function returns none as the return value</b><br><br>answer: some-function 42<br>== none<br><br>print none? answer<br><b style="color: blue">true</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="nonexex"> none!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The none! datatype contains a single value that represents nothing or no <br>value. See <a href="./index.html#none">none</a> for more details.<br><br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="nonexqm"> none?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#nonexqm">none?</a> returns <a href="./index.html#true">true</a> if its argument has a <a href="./index.html#none">none</a> value,<br>otherwise <a href="./index.html#false">false</a>.<br><br>Its single argument can be of any type.<br></pre>例子<pre>red>> none? 3 / 4<br>== false<br><br><b style="color: green">; Find searches and returns <a href="./index.html#none">none</a> if not found</b><br>red>> none? find "ABCD" "Z"<br>== true<br><br><b style="color: green">; If found, returns the <a href="./index.html#seriesxex">series!</a> from the found item ("BCD").</b><br>red>> none? find "ABCD" "B"<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="normalize-dir"> normalize-dir</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="not"> not</span> type: native! Categories: <a href="./index.html#cat-b02">位操作</a>, <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>关键字 <a href="./index.html#not">not</a> returns the logical complement of a value.<br><br>NOTE that only the <a href="./index.html#logicxex">logic!</a> values <a href="./index.html#false">false</a> and <a href="./index.html#none">none</a><br> return <a href="./index.html#true">true</a>.<br><br>For other types such as <a href="./index.html#integerxex">integer!</a>, <a href="./index.html#floatxex">float!</a>, <a href="./index.html#bitsetxex">bitset!</a>,<br><a href="./index.html#false">false</a> is returned, irrespective of the data value.<br><br>Use <a href="./index.html#complement">complement</a> to perform a bitwise <a href="./index.html#not">not</a>.<br></pre>例子<pre>red>> not (3 > 2)<br>== false<br><br>red>> not (10 > 20)<br>== true<br><br>red>> not 1<br>== false<br><br>red>> not 0<br>== false<br><br>red>> not -1<br>== false<br><br>red>> not none<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="not-equalxqm"> not-equal?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#not-equalxqm">not-equal?</a> returns <a href="./index.html#true">true</a> if two values (of any type)<br>are not equal.<br><br>When comparing <a href="./index.html#stringxex">string!</a>s lowercase is considered equal to uppercase.<br><br>There is also an infix <a href="./index.html#xltxgt"><></a> operator, doing the same.<br></pre>例子<pre>red>> not-equal? 12 12.0<br>== false<br><br>red>> not-equal? "abc" "abc"<br>== false<br><br>red>> not-equal? "abC" "ABC"<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="now"> now</span> type: native! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="numberxex"> number!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#numberxex">number!</a> is a <a href="./index.html#typesetxex">typeset!</a> containing other <a href="./index.html#datatypexex">datatype!</a>s.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show all subtypes of <a href="./index.html#numberxex">number!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ? number!<br>number! is a typeset! of value: <br> make typeset! [<br> integer! <br> float! <br> percent!<br> ]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="object"> object</span> type: function! Categories: <a href="./index.html#cat-o01">对象</a><br><pre>An <a href="./index.html#object">object</a> is a container that groups data and/or functions within <br>one variable.<br><br>Red implements 'prototype-based objects'. <br><br>Creating new <a href="./index.html#object">object</a>s is done by cloning existing <a href="./index.html#object">object</a>s <br>or the base <a href="./index.html#objectxex">object!</a> value. <br><br>During the creation process, existing field values can be modified <br>and new fields can be added. <br><br>It is a very simple and efficient model to encapsulate your Red code.<br></pre>例子<pre><b style="color: green">; <a href="./index.html#make">make</a> an <a href="./index.html#object">object</a> - a pretend square box</b><br>box: make object! [<br> size: 10<br> show: function [] [<br> print ["Showing size =" size "from within the box!"]<br> ]<br>]<br><br><b style="color: green">; Use the encapsulated function</b><br>box/show<br><b style="color: blue">Showing size = 10 from within the box!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="objectxex"> object!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>Object Model<br>------------<br> Red implements prototype-based objects. Creating new objects is done <br> by cloning existing objects or the base object! value. During the creation <br> process, existing field values can be modified and new fields can be added. <br> It is a very simple and efficient model to encapsulate your Red code. <br><br>Object Creation<br>---------------<br>We create new objects by:<br><br> make object! <specification block><br> <br>There are also some shorter alternative syntaxes (just handy shortcuts):<br><br> <a href="./index.html#object">object</a> <specification block><br> <a href="./index.html#context">context</a> <specification block><br><br>The specification block can contain any valid Red code. Words set at the root<br>level of that block will be collected and will constitute the new object's fields. <br> <br>You can put any valid code into a specification block, and it will be evaluated <br>during the object construction, and only then. Here is an example. Note that <br>"hello" is printed when we make the object, but not when we evaluate it:<br><br>red>> obj: make object! [print "hello" a: 1 b: 2]<br>hello<br>== make object! [<br> a: 1<br> b: 2<br>]<br><br>;now use it<br>red>> obj<br>== make object! [<br> a: 1<br> b: 2<br>]<br><br><br>Nesting<br>-------<br>Objects can also be nested easily:<br> obj: object [<br> a: 123<br> b: object [<br> c: "hello"<br> d: object [<br> data: none<br> ]<br> ]<br> ]<br><br>Another way to create an object is to use the <a href="./index.html#copy">copy</a> action which does not <br>require a specification block, so does just a simple cloning of the object. <br>Existing functions will be re-bound to the new object.<br><br>Syntax:<br> copy <object><br><br>Object Access Paths<br>-------------------<br><br>In order to access object fields, the common path syntax is used (words <br>separated by a slash character). Each word (or expression) in a path is <br>evaluated in the context given by the left side of the path. Evaluation <br>of a word referring to a function will result in invoking the function, <br>with its optional refinements.<br><br>Example:<br><br> book: object [<br> title: author: none<br> show: does [print [mold title "was written by" author]]<br> ]<br><br> book/title: "The Time Machine"<br> book/author: "H.G.Wells"<br> print book/title<br> book/show<br><br>will output:<br> <br> The Time Machine<br> "The Time Machine" was written by H.G.Wells<br><br>SELF Reference<br>--------------<br><br>A special keyword named <a href="./index.html#self">self</a> has been reserved when self-referencing <br>the object is required.<br><br>Example:<br><br> book: object [<br> title: author: none<br> list-fields: does [words-of self]<br> ]<br> book/list-fields<br><br>will output: <br><br> [title author list-fields]<br><br><br>Object inheritance<br>------------------<br><br>Though cloning produces exact replicas of the prototype object, it is also <br>possible to extend it in the process, using <a href="./index.html#make">make</a> action.<br><br>Syntax:<br> make <prototype> <spec><br><br> <prototype> : object that will be cloned and extended<br> <spec> : specification block<br><br>Example:<br> a: object [value: 123]<br> <br> c: make a [<br> increment: does [value: value + 1]<br> ]<br> <br> print c/increment<br> print c/increment<br><br>will output: <br><br> 124<br> 125<br><br>It is also possible to use another object as <spec> argument. In such <br>case, both objects are merged to form a new one. The second object takes <br>priority in case both objects share same field names.<br> <br>Example:<br> a: object [<br> value: 123<br> show: does [print value]<br> ]<br> b: object [value: 99]<br> <br> c: make a b<br> c/show<br><br>will output: <br><br> 99<br> <br><br>Extended Actions and Natives for Objects<br>----------------------------------------<br><br>You can use <a href="./index.html#set">set</a> on an object to set all fields at the same time, and <br><a href="./index.html#get">get</a> on an object will return a block of all the fields values. <br><br>Example:<br><br> obj: object [a: 123 b: "hello"]<br> probe get obj<br> set obj none<br> ?? obj<br> set obj [hello 0]<br> ?? obj<br> probe :obj/a<br><br>will output: <br><br> [123 "hello"]<br> obj: make object! [<br> a: none<br> b: none<br> ]<br> obj: make object! [<br> a: 'hello<br> b: 0<br> ]<br> hello<br><br>The <a href="./index.html#find">find</a> function gives you a simple way to check for a field name in <br>an object. If found it will return <a href="./index.html#true">true</a>, else <a href="./index.html#none">none</a>.<br><br>The <a href="./index.html#select">select</a> action does the same check as <a href="./index.html#find">find</a>, but returns the field <br>value for matched word.<br> obj: object [a: 123]<br> probe find obj 'a<br> probe select obj 'a<br> probe find obj 'hello<br><br>will output: <br><br> true<br> 123<br> none<br><br>The <a href="./index.html#in">in</a> word will allow you to bind a word to a target context:<br><br> a: 0<br> obj: object [a: 123]<br> probe a<br> probe get in obj 'a<br><br>will output:<br><br> 0<br> 123<br><br>The <a href="./index.html#bind">bind</a> function is also available.<br><br>Reflectors<br>----------<br><br>The reflective functions <a href="./index.html#words-of">words-of</a>, <a href="./index.html#values-of">values-of</a>, <a href="./index.html#body-of">body-of</a> can be <br>used to access an object's internal structure.<br><br><br>These notes are heavily based on <br><a href="http://www.red-lang.org/2014/12/050-objects-support.html">http://www.red-lang.org/2014/12/050-objects-support.html</a><br><br><br><br><br><br><br> <br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="objectxqm"> object?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#objectxqm">object?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#objectxex">object!</a>.<br><br>The single argument can be of any type.<br></pre>例子<pre><b style="color: green">; <a href="./index.html#make">make</a> an <a href="./index.html#object">object</a> - a pretend square box</b><br>red>> box: make object! [<br>[ size: 10<br>[ show: function [] [<br>[ print ["Showing size =" size "from within the box!"]<br>[ ]<br>[ ]<br>== make object! [<br> size: 10<br> show: func [][<br> print ["...<br> <br><b style="color: green">; Is this an object?</b> <br>red>> object? box<br>== true<br><br><b style="color: green">; Definitely not an object</b><br>red>> amounts: [2 3 4]<br>== [2 3 4]<br><br>red>> object? amounts<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="oddxqm"> odd?</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#oddxqm">odd?</a> returns <a href="./index.html#true">true</a> if its numeric parameter is odd,<br>else returns <a href="./index.html#false">false</a>.<br><br>Has 1 numeric parameter, which should be an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre>odd? -3<br>== true<br><br>odd? 10<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="off"> off</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a><br><pre>关键字 <a href="./index.html#off">off</a> has the logical value "false" <br>and its <a href="./index.html#datatypexex">datatype!</a> is <a href="./index.html#logicxex">logic!</a><br><br>Logical values are produced from various comparisons.<br><br>The <a href="./index.html#logicxex">logic!</a> type also provides: <br> <a href="./index.html#false">false</a>, <a href="./index.html#no">no</a>, <a href="./index.html#on">on</a>, <a href="./index.html#true">true</a>, <a href="./index.html#yes">yes</a><br></pre>例子<pre>red>> ? off<br>off is a logic! of value: false<br><br>red>> either off [print "t is true"] [print "t is NOT true"]<br><b style="color: blue">t is NOT true</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="on"> on</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>关键字 <a href="./index.html#on">on</a> has the logical value "true" <br>and its <a href="./index.html#datatypexex">datatype!</a> is <a href="./index.html#logicxex">logic!</a><br><br>Logical values are produced from various comparisons.<br><br>The <a href="./index.html#logicxex">logic!</a> type also provides: <br> <a href="./index.html#false">false</a>, <a href="./index.html#no">no</a>, <a href="./index.html#off">off</a>, <a href="./index.html#true">true</a>, <a href="./index.html#yes">yes</a><br></pre>例子<pre>red>> ? on<br>on is a logic! of value: true<br><br>red>> either on [print "It is true!"] [print ["It is NOT true!"]]<br><b style="color: blue">It is true!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="opxex"> op!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#opxex">op!</a> represents the Red functions that act as infix <br>operators.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; List all infix operators with type <a href="./index.html#opxex">op!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ? op!<br> % => Returns what is left over when one value is divided by another<br> * => Returns the product of two values<br> ** => Returns a number raised to a given power (exponent)<br> + => Returns the sum of the two values<br>- => Returns the difference between two values<br> / => Returns the quotient of two values<br> // => Compute a nonnegative remainder of A divided by B<br> < => Returns TRUE if the first value is less than the second<br> << <br> <= => Returns TRUE if the first value is less than or equal <br> to the second<br> <> => Returns TRUE if two values are not equal<br> = => Returns TRUE if two values are equal<br> == => Returns TRUE if two values are equal, and also the <br> same datatype<br> =? => Returns TRUE if two values have the same identity<br> > => Returns TRUE if the first value is greater than the second<br> >= => Returns TRUE if the first value is greater than or equal to <br> the second<br> >> <br> >>> <br> and => Returns the first value ANDed with the second<br> is => Defines a local reactive relations inside a reactor<br> or => Returns the first value ORed with the second<br> xor => Returns the first value exclusive ORed with the second<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples of infix operations</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> 1 + 2<br>== 3<br><br>red>> 2 * 5<br>== 10<br><br>red>> 10 / 2<br>== 5<br><br>red>> 10 // 2<br>== 0<br><br>red>> 10 // 3<br>== 1<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="opxqm"> op?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#opxqm">op?</a> returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#opxex">op!</a> type. <br><br>This type includes infix operators, such as <a href="./index.html#xpl">+</a> <a href="./index.html#-">-</a> <a href="./index.html#xmu">*</a> etc).<br><br>Note the use of : to prevent evaluation of the argument!<br></pre>例子<pre>red>> op? :and<br>== true<br><br>red>> op? :print<br>== false<br><br>red>> op? :+<br>== true<br><br>red>> op? :-<br>== true<br><br>red>> op? :float?<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="or"> or</span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a>, <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>中缀词<a href="./index.html#or">or</a> performs a logical "or" of two values.<br>The values are restricted to these types:<br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <br> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple! </a>#vector!<br><br>It is the infix version of the word <a href="./index.html#orxsn">or~</a>.<br><br>In the case of <a href="./index.html#or">or</a>ing two <a href="./index.html#integerxex">integer!</a>s (or closely related types,<br>such as <a href="./index.html#charxex">char!</a> and <a href="./index.html#pairxex">pair!</a>), a bitwise (bit-by-bit) process is performed.<br><br>In general, types can be mixed, but <a href="./index.html#logicxex">logic!</a> types cannot be mixed with other types.<br><br>The type of the result is the same type as the first value for a bitwise <a href="./index.html#or">or</a>.<br>For a <a href="./index.html#logicxex">logic!</a> <a href="./index.html#or">or</a>, <a href="./index.html#true">true</a> or <a href="./index.html#false">false</a> are returned.<br></pre>例子<pre>red>> (3 > 2) or false<br>== true<br><br>red>> 8 or 16<br>== 24<br><br>red>> 16 or false<br>*** Script error: logic type is not allowed here<br>*** Where: or<br><br>red>> my-pair: 3x4<br>== 3x4<br><br>red>> my-pair or 1<br>== 3x5<br><br>red>> 1 or my-pair<br>*** Script error: or does not allow pair for its value2 argument<br>*** Where: or<br><br>red>> v1: make vector![1 2 3]<br>== make vector! [1 2 3]<br><br>red>> v2: make vector![1 1 1]<br>== make vector! [1 1 1]<br><br>red>> v1 or v2<br>== make vector! [1 3 3]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="orxsn"> or~</span> type: action! Categories: <a href="./index.html#cat-b02">位操作</a>, <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-l01">逻辑</a><br><pre>The <a href="./index.html#orxsn">or~</a> word performs a logical "or" of its 2 arguments.<br>The values are restricted to these types:<br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>It is the functional version of the infix word <a href="./index.html#or">or</a>.<br><br>In the case of <a href="./index.html#orxsn">or~</a>ing two <a href="./index.html#integerxex">integer!</a>s (or types closely related to integers,<br>such as <a href="./index.html#charxex">char!</a>, <a href="./index.html#pairxex">pair!</a>), a bitwise (bit-by-bit) process is performed.<br><br>In general, types can be mixed, but <a href="./index.html#logicxex">logic!</a> types cannot be mixed with other types.<br><br>The type of the result is the same type as the first value for a bitwise <a href="./index.html#orxsn">or~</a>.<br>For a logic <a href="./index.html#orxsn">or~</a>, <a href="./index.html#true">true</a> or <a href="./index.html#false">false</a> are returned.<br></pre>例子<pre>red>> or~ (3 > 2) false<br>== true<br><br>red>> or~ 8 16<br>== 24<br><br>red>> or~ 16 false<br>*** Script error: logic type is not allowed here<br>*** Where: or~<br><br>red>> my-pair: 3x4<br>== 3x4<br><br>red>> or~ my-pair 1<br>== 3x5<br><br>red>> or~ 1 my-pair<br>*** Script error: or~ does not allow pair for its value2 argument<br>*** Where: or~<br><br>red>> v1: make vector![1 2 3 1:]<br>== make vector! [1 2 3]<br><br>red>> v2: make vector![1 1 1]<br>== make vector! [1 1 1]<br><br>red>> or~ v1 v2<br>== make vector! [1 3 3]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pad"> pad</span> type: function! Categories: <a href="./index.html#cat-f02">格式化</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#pad">pad</a> pads a <a href="./index.html#stringxex">string!</a> on the right side with spaces.<br><br>The arguments are:<br> 1. the <a href="./index.html#stringxex">string!</a> to pad<br> 2. the total size (<a href="./index.html#integerxex">integer!</a>) of the new <a href="./index.html#stringxex">string!</a>.<br><br>Refinements:<br> /left - pads the <a href="./index.html#stringxex">string!</a> at its left side.<br></pre>例子<pre><b style="color: green">; Note the 4 (i.e. 6 - 2) spaces between B and X</b><br>red>> prin "X" prin pad "AB" 6 print "X" print "-123456-"<br><b style="color: blue">XAB X</b><br><b style="color: blue">-123456-</b><br><br><b style="color: green">; Note the 4 spaces between the X and A</b><br>red>> prin "X" prin pad/left "AB" 6 print "X" print "-123456-"<br><b style="color: blue">X ABX</b><br><b style="color: blue">-123456-</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pairxex"> pair!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#pairxex">pair!</a> represents a <a href="./index.html#scalarxex">scalar!</a> type containing <br>2 values.<br><br>A pair looks like:<br> axb<br> <br>Pairs can be used to represent points in Cartesian space. (Coordinates)<br><br>The constituents of a <a href="./index.html#pairxex">pair!</a> can be retrieved as follows:<br> - retrieve left value by either pairname/1 or pairname/x<br> - retrieve right value by either pairname/2 or pairname/y<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> coord1: 10x20<br>== 10x20<br><br>red>> coord2: 100x100<br>== 100x100<br><br>red>> coord1 + coord2<br>== 110x120<br><br>red>> coord1 * coord2 <br>== 1000x2000<br><br>red>> coord1/x<br>== 10<br><br>red>> coord1/1<br>== 10<br><br>red>> coord2/y: 234<br>== 234<br><br>red>> coord2<br>== 100x234<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pairxqm"> pair?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#pairxqm">pair?</a> returns <a href="./index.html#true">true</a> if its argument is of <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#pairxex">pair!</a>.<br><br>The argument can be of any type.<br><b style="color: green">; Integer</b><br>red>> pair? 123<br>== false<br><br><b style="color: green">; Tuple</b><br>red>> pair? 1.2.33<br>== false<br><br><b style="color: green">; Pair</b><br>red>> pair? 22x33<br>== true<br><br><b style="color: green">; Result of adding 2 pairs</b><br>red>> pair? 22x33 + 1x1<br>== true<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="parenxex"> paren!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>A paren! is a <a href="./index.html#seriesxex">series!</a> of items enclosed in parentheses ( ). It is <br>evaluated when it is encountered, and a result is returned.<br><br>In Red, infix operators have no priority, and paren! types can sometimes add <br>clarity.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Work with infix operators</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> (1 + 2)<br>== 3<br><br>red>> 3 + ((4 + 5) * (2 + 3))<br>== 48<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Preventing evaluation with e.g. [ ]</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> first [(2 + 3)]<br>== (2 + 3)<br><br>;a paren! is a series!<br>red>> first first [(2 + 3)]<br>== 2<br><br>;here 2 + 3 is evaluated first, so first tries to work on 5<br>red>> first (2 + 3)<br>*** Script Error: first does not allow integer! for its s argument<br>*** Where: first<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="parenxqm"> paren?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>Returns true if its argument is a <a href="./index.html#parenxex">paren!</a> type, otherwise false.<br><br>The single argument can be of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Exercise paren?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; The paren! is evaluated first. Paren? 3 is false<br>red>> paren? (1 + 2)<br>== false<br><br>; the paren! is evaluated first<br>red>> paren? [(1 + 2)]<br>== false<br><br>;'first fetches a paren!<br>red>> paren? first [(1 + 2)]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="parse"> parse</span> type: native! Categories: <a href="./index.html#cat-p01">解析</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="parse-trace"> parse-trace</span> type: function! Categories: <a href="./index.html#cat-p01">解析</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="pathxex"> path!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a>, <a href="./index.html#cat-o01">对象</a>, <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-u02">URL</a><br><pre>A <a href="./index.html#pathxex">path!</a> is used to access items, often those contained in larger <br>structures. The path! syntax is basically a series of items (including <br><a href="./index.html#parenxex">paren!</a>) separated by '/', and is applicable to a range of data types. <br>It might help your understanding if you look at the lower-level <br><a href="./index.html#get-wordxex">get-word!</a>, <a href="./index.html#set-wordxex">set-word!</a> and <a href="./index.html#lit-wordxex">lit-word!</a> types first. Here are some <br>introductory examples of path!.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; with series - string and block</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> str: "ABCDE"<br><br>;get element 3<br>red>> str/3<br>== #"C"<br><br>;get element 2. NB b/2, not b / 2, which divides.<br>red>> b: [11 22 33 44]<br>red>> b/2<br>== 22<br> <br>;with a paren! in a path<br>red>> b/(1 + 2)<br>== 33<br><br>red>> n: 1<br>red>> b/(n + 1)<br>== 22<br><br>;here, b has a nested block at position 4<br>red>> b: [11 22 33 [444 555] 66]<br>;get element 4, position 1<br>red>> b/4/1<br>== 444<br><br>;now with words, not literal numbers<br>red>> x: 4<br>red>> y: 1<br><br>;get element with a get-path! Note preceding : (more on this below)<br>red>> b/:x/:y<br>== 444<br><br>;set elementwith a set-path! Note following : (more on this below)<br>red>> b/:x/:y: 1111<br>== 1111<br>;note the changed value<br>red>> b<br>== [11 22 33 [1111 555] 66]<br><br>;with symbols - here, the value AFTER the symbol is returned<br>red>> sales: [UK 10000 USA 15000 China 33000]<br>red>> sales/USA<br>== 15000<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Path Examples With Refinement </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>Many function words use 'refinements' to modify their action. Here is <br><a href="./index.html#sort">sort</a> with its reverse refinement:<br>red>> ages: [55 33 73 73 19]<br>red>> sort/reverse ages<br>== [73 73 55 33 19]<br><br>Using Paths - set/get/lit Paths <br>-------------------------------<br><br>When we use colons or ticks in a path, the type of the path becomes a <br><a href="./index.html#set-pathxex">set-path!</a>, a <a href="./index.html#get-pathxex">get-path!</a>, or a <a href="./index.html#lit-path">lit-path</a>. This is similar in <br>concept to <a href="./index.html#get-wordxex">get-word!</a>, <a href="./index.html#set-wordxex">set-word!</a> and <a href="./index.html#lit-wordxex">lit-word!</a>.<br><br>If we have a block such as:<br><br>b: [11 22 33 44]<br><br>then we can use numbers in a straightforward way, as in:<br><br>b/2 ; get element at position 2<br>b/2: 2222 ; set element at position 2<br><br>With words used as variables, we must use <a href="./index.html#set-pathxex">set-path!</a> and <a href="./index.html#get-pathxex">get-path!</a> <br>types, as in:<br><br>red>> b/:x/:y ;get-path! type<br><br>red>> b/:x/:y: 1111 'set-path! type<br><br><br>We can also use a <a href="./index.html#lit-pathxex">lit-path!</a> type, as in:<br><br>'b/x<br><br>which evaluates to <br><br>b/x<br><br><br>Paths As Series<br>---------------<br><br>A path is a series, and its elements can be accessed with the <a href="./index.html#seriesxex">series!</a> functions. <br><br>Here, the first [block] is used to prevent evaluation<br><br>red>> second first [the/white/cat]<br>== white<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pathxqm"> path?</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-o01">对象</a>, <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-t01">类型检查</a>, <a href="./index.html#cat-u02">URL</a><br><pre>关键字 <a href="./index.html#pathxqm">path?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#pathxex">path!</a> type.<br>Otherwise <a href="./index.html#false">false</a>.<br><br>Its single argument can be of any type.<br><br>There are several types of <a href="./index.html#pathxex">path!</a> related words:<br> <a href="./index.html#pathxex">path!</a> <a href="./index.html#lit-pathxex">lit-path!</a> <a href="./index.html#set-pathxex">set-path!</a> <a href="./index.html#get-pathxex">get-path!</a><br><br>To test if an argument is any of these types, use <a href="./index.html#any-pathxqm">any-path?</a>. <br>To restrict the test to <a href="./index.html#pathxex">path!</a> only, use <a href="./index.html#pathxqm">path?</a><br><br>For more details on the ways of interpreting a word (involving ' and :), <br>the reader should look at the entries on <a href="./index.html#lit-wordxex">lit-word!</a> <a href="./index.html#get-wordxex">get-word!</a> and <a href="./index.html#set-wordxex">set-word!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; With a get-path! type - false</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> path? first [:a/b/c]<br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; With a path! - true</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> path? first [a/b/c]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="percentxex"> percent!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#percentxex">percent!</a> represents a <a href="./index.html#numberxex">number!</a> type containing <br>32 bit whole signed numbers.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> 35 * 10%<br>== 3.5<br><br>red>> 35 * (10.0 / 100) <b style="color: green">; Exactly the same</b><br>== 3.5<br><br>red>> 100% / 40% <b style="color: green">; Not so useful?</b><br>== 250%<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="percentxqm"> percent?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#percentxqm">percent?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#percentxex">percent!</a> type, <br>otherwise <a href="./index.html#false">false</a>.<br><br>The argument can be any type.<br></pre>例子<pre>red>> x: 100%<br>== 100%<br><br>red>> percent? x<br>== true<br><br>red>> y: 200<br>== 200<br><br>red>> percent? y<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pi"> pi</span> type: float! Categories: <a href="./index.html#cat-c05">常量</a>, <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#pi">pi</a> is a mathematical constant.<br><br>It can be roughly approached by dividing 22 by 7.<br></pre>例子<pre>red>> ? pi<br>pi is a float! of value: 3.141592653589793<br><br>red>> 22.0 / 7<br>== 3.142857142857143<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="pick"> pick</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#pick">pick</a> takes the nth value of a <a href="./index.html#seriesxex">series!</a>, where n is the second argument<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a <a href="./index.html#blockxex">block!</a> of numbers</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: [1 2 3 4 5 6 7 8]<br>== [1 2 3 4 5 6 7 8]<br><br>red>> y: pick x 4<br>== 4<br><br>red>> x<br>== [1 2 3 4 5 6 7 8]<br><br>red>> y<br>== 4<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdefghijklmnopqrstuvwxyz"<br>== "abcdefghijklmnopqrstuvwxyz"<br><br>red>> pick s 1<br>== #"a"<br><br>red>> pick s 26<br>== #"z"<br><br>red>> pick s 27<br>== none <b style="color: green">; Index out of range</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a <a href="./index.html#blockxex">block!</a> of <a href="./index.html#stringxex">string!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> p: ["abc" "def" "ghi" "jkl" "mno" "pqr" "stu"]<br>== ["abc" "def" "ghi" "jkl" "mno" "pqr" "stu"]<br><br>red>> pick p 1<br>== "abc"<br><br>red>> pick p 4<br>== "jkl"<br><br>red>> pick p -1<br>== none <b style="color: green">; Index out of range</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="point"> point</span> type: unset! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="pointxex"> point!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#pointxex">point!</a> represents points in the Cartesian coordinate<br>system. A point on the X-Y-axis.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> p: 100x100<br>== 100x100<br><br>red>> q: 2<br>== 2<br><br>red>> p * q<br>== 200x200<br><br>red>> x: 10x10<br>== 10x10<br><br>red>> y: 2x3<br>== 2x3<br><br>red>> x * y<br>== 20x30<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="poke"> poke</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>The word poke changes an element of a <a href="./index.html#seriesxex">series!</a> to a value.<br><br>Arguments:<br> - name of the <a href="./index.html#seriesxex">series!</a><br> - the index of the element to be replaced<br> - the new value for that element<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using a <a href="./index.html#blockxex">block!</a> of numbers</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> x: [1 2 3 4 5 6 7 8 9]<br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> poke x 3 66<br>== 66<br><br>red>> x<br>== [1 2 66 4 5 6 7 8 9]<br><br>red>> poke x 11 12<br>*** Script Error: value out of range: 11<br>*** Where: poke<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; using a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdefghijklmnop"<br>== "abcdefghijklmnop"<br><br>red>> poke s 3 #"C"<br>== #"C"<br><br>red>> s<br>== "abCdefghijklmnop"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="positivexqm"> positive?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#positivexqm">positive?</a> returns <a href="./index.html#true">true</a> if the numeric parameter <br>is greater than 0, otherwise <a href="./index.html#false">false</a>.<br><br>NOTE that zero returns <a href="./index.html#false">false</a>.<br><br>Has one numeric parameter.<br></pre>例子<pre>positive? -2<br>== false<br><br>positive? 0<br>== false<br><br>positive? 0.1<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="power"> power</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#power">power</a> returns the value of a <a href="./index.html#numberxex">number!</a> raised to a given power (exponent).<br><br>It is the functional version of the infix word <a href="./index.html#xmuxmu">**</a>.<br><br>It has 2 arguments: a base value and a power, both <a href="./index.html#numberxex">number!</a>s.<br></pre>例子<pre>red>> power 3.1 2<br>== 9.61<br><br>red>> power 100.9 0.5<br>== 10.04489920307815<br><br>red>> power 2 10<br>== 1024<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="prin"> prin</span> type: native! Categories: <a href="./index.html#cat-c04">控制台</a>, <a href="./index.html#cat-o02">输出</a><br><pre>关键字 <a href="./index.html#prin">prin</a> outputs a value to the Red console in a similar manner to <br>the <a href="./index.html#print">print</a> word, but without emitting an end-of-line: "^(line)".<br><br>For more details, look at <a href="./index.html#print">print</a>.<br></pre>例子<pre>red>> prin 3 + 3 prin 4 + 4 print "done"<br><b style="color: blue">68done</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="print"> print</span> type: native! Categories: <a href="./index.html#cat-c04">控制台</a>, <a href="./index.html#cat-o02">输出</a><br><pre>关键字 <a href="./index.html#print">print</a> outputs its argument to the Red console, followed by a <br>new-line: "^(line)".<br><br>The single argument can be any type (also a <a href="./index.html#blockxex">block!</a>).<br><br>The twin word <a href="./index.html#prin">prin</a> does the same but without outputting new-line.<br></pre>例子<pre>red>> area: 3 * 2<br>== 6<br><br>red>> print area<br>6<br><br>red>> print area * 10<br>60<br><br>red>> print "Hello"<br>Hello<br><br><b style="color: green">; Block is useful for printing several items</b><br><b style="color: green">; Note: print will insert a space between the items in the block!</b><br>red>> print ["Area is" area "square units"]<br><b style="color: blue">Area is 6 square units</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="probe"> probe</span> type: function! Categories: <a href="./index.html#cat-c04">控制台</a><br><pre>关键字 <a href="./index.html#probe">probe</a> returns its argument, after <a href="./index.html#print">print</a>ing it in its <a href="./index.html#mold">mold</a>ed form.<br><br>Its argument can be of any type.<br><br>Have a look at <a href="./index.html#mold">mold</a> for specifics on the formatting.<br></pre>例子<pre><b style="color: green">; Behavior of print</b><br>red>> print [1 2 3]<br><b style="color: blue">1 2 3</b><br><br><b style="color: green">; Behavior of mold</b><br>red>> probe [1 2 3]<br><b style="color: blue">[1 2 3]</b><br>== [1 2 3]<br><br><b style="color: green">; Note the molded form</b><br>red>> probe #"A"<br><b style="color: blue">#"A"</b><br>== #"A"<br><br><b style="color: green">; Same but now printed</b><br>red>> print probe #"A"<br><b style="color: blue">#"A"</b><br><b style="color: blue">A</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="put"> put</span> type: action! Categories: <a href="./index.html#cat-m01">图</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="pwd"> pwd</span> type: unset! Categories: <a href="./index.html#cat-d01">目录</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="q"> q</span> type: unset! <pre>This word is a synonym for <a href="./index.html#quit">quit</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="quit"> quit</span> type: function! Categories: <a href="./index.html#cat-e03">退出</a>, <a href="./index.html#cat-s05">系统相关</a><br><pre>关键字 <a href="./index.html#quit">quit</a> quits the interpreter (and thus the program) immediately.<br><br>Refinement:<br> /return p - When this refinement is used value p is returned by <a href="./index.html#quit">quit</a>.<br></pre>例子<pre>quit<br><b style="color: green">; returns immediately to the OS command prompt</b><br><br>quit/return 3<br><b style="color: green">; returns to the OS command prompt and hands the OS the value 3</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="quit-return"> quit-return</span> type: routine! Categories: <a href="./index.html#cat-e03">退出</a>, <a href="./index.html#cat-s05">系统相关</a><br><pre>关键字 <a href="./index.html#quit-return">quit-return</a> stops evaluation and exits the program <br>with a given return code.<br><br>The argument is the return code, an <a href="./index.html#integerxex">integer!</a>.<br></pre>例子<pre>data: 1234<br>either data > 0<br> [quit-return 1]<br> [quit-return 0]<br><b style="color: green">; This program returns 1 to the OS. This is the program's return code.</b><br><b style="color: green">; Ways of handling this depend on the particular OS.</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="quote"> quote</span> type: function! Categories: <a href="./index.html#cat-w01">标识符操作</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="random"> random</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#random">random</a> returns a random value of the same type as its single argument.<br>For certain types and refinements, it can shuffle or pick from a <a href="./index.html#seriesxex">series!</a>.<br><br>For an <a href="./index.html#integerxex">integer!</a> argument of value n, the random value is between 1 and n inclusive.<br><br>Refinements<br> /seed - Restart or randomize<br> /secure - Returns a cryptographically secure random <a href="./index.html#numberxex">number!</a><br> /only - Pick a random value from a <a href="./index.html#seriesxex">series!</a><br></pre>例子<pre>red>> random 2<br>== 1<br><br>red>> random 2<br>== 2<br><br>red>> random 1.0<br>== 0.4107365828988778<br><br>red>> random "fish"<br>== "ifhs"<br><br>red>> random/only "abcde"<br>== #"a"<br><br>red>> random [1 2 3 4]<br>== [2 1 4 3]<br><br>red>> random/only ["stone" "paper" "scissors"]<br>== "scissors"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="reactxqm"> react?</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="read"> read</span> type: action! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-i01">输入</a>, <a href="./index.html#cat-u02">URL</a><br><pre>关键字 <a href="./index.html#read">read</a> reads and returns data from a <a href="./index.html#filexex">file!</a>. <br><br>The argument must be a <a href="./index.html#filexex">file!</a> type.<br><br>Refinements:<br> /binary - reads, and preserves contents exactly<br> /lines - reads lines of text, placing them in a <a href="./index.html#blockxex">block!</a> of <a href="./index.html#stringxex">string!</a>s.<br> /info - <br> /part<br> /as<br> /seek<br></pre>例子<pre><b style="color: green">; The following example was executed on Windows, using a text file created with</b><br><b style="color: green">; Notepad, and placed in the same folder as the program. The file contains 2 lines:</b><br><br><b style="color: green">; LINE1</b><br><b style="color: green">; LINE2</b><br><br><b style="color: green">; Inside the file, the end of each line is marked by a CRLF pair.</b><br><b style="color: green">; However, when Red reads the data as text, it presents the data to us with only</b><br><b style="color: green">; the LF character at the end, just as on Linux.</b><br><br><b style="color: green">; 1) read a file as strings</b><br><br>text: read %read-data.txt<br><br>print length? text <b style="color: green">; 12 characters</b><br><b style="color: blue">12</b><br><br>prin text <b style="color: green">; Displays all the lines. No extra newline</b><br><b style="color: blue">LINE1</b><br><b style="color: blue">LINE2</b><br><br><b style="color: green">; 2) read a file as binary</b><br><br>bin: read/binary %read-data.txt<br><br>print length? bin <b style="color: green">; 14 bytes</b><br><b style="color: blue">14</b><br><br>print bin <b style="color: green">; In hex format</b><br><b style="color: blue">#{4C494E45310D0A4C494E45320D0A}</b><br><br><b style="color: green">; 3) read individual lines (strings)</b><br><br>text: read/lines %read-data.txt<br><br>print length? pick text 1 <b style="color: green">; Length is 5 - no LF</b><br><b style="color: blue">5</b><br><br>print pick text 2 <b style="color: green">; Print second line</b><br><b style="color: blue">LINE</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="red-complete-file"> red-complete-file</span> type: unset! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="red-complete-path"> red-complete-path</span> type: unset! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="reduce"> reduce</span> type: native! Categories: <a href="./index.html#cat-e02">评估</a><br><pre>关键字 <a href="./index.html#reduce">reduce</a> returns a copy of a <a href="./index.html#blockxex">block!</a>, evaluating all expressions<br>in the <a href="./index.html#blockxex">block!</a>.<br><br>Its single argument can be of any type.<br><br>Refinements<br> /into - puts results into a provided <a href="./index.html#blockxex">block!</a>, instead of creating a new one.<br> <br></pre>例子<pre>red>> reduce[1 + 2 5 * 6]<br>[3 30]<br><br>red>> b: reduce[1 + 5]<br>[6]<br><br>red>> b<br>[6]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use the /into refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> a-block: []<br>[]<br><br>red>> reduce/into [4 5 + 6] a-block<br>[]<br><br>red>> a-block<br>[4 11]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Evaluating can also mean assignment</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> var: 3<br>3<br><br>red>> reduce [ 3 * 3 var: 22]<br>[9 22]<br><br>red>> var<br>22<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Single values, variables or expressions (not in a block)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> reduce 123<br>123<br><br>red>> reduce 1 + 2<br>3<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="refinementxex"> refinement!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>A refinement! <a href="./index.html#datatypexex">datatype!</a> indicates a variation in the use of, or <br>extension in the meaning of, a <a href="./index.html#functionxex">function!</a>, <a href="./index.html#objectxex">object!</a>, <a href="./index.html#filexex">file!</a>, <a href="./index.html#urlxex">url!</a>, or <br><a href="./index.html#pathxex">path!</a>. The exact usage of a refinement varies. For example, <br><a href="./index.html#function">function</a> refinements can be written so they require additional <br>arguments. We might also use several refinements at once. Refinements <br>start with a /, followed by a valid Red word. Below, we use the <br><a href="./index.html#refinementxqm">refinement?</a> function to examine some possibilities.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; try refinement?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> refinement? /part<br>== true<br>red>> refinement? /45<br>== true<br>red>> refinement? /:b ; this is a set-word! type<br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; refinement with function. The 3 is the argument of /part</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [8 7 6 5 4 3 2]<br>red>> sort/part s 3<br>== [6 7 8 5 4 3 2] ; Only the first 3 items were sorted<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; refinement with an object</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print system/version<br>== 0.6.1<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; refinement as a path to a block element</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [11 22 33 44]<br>red>> b/2<br>== 22<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="refinementxqm"> refinement?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>The <a href="./index.html#refinementxqm">refinement?</a> word returns <a href="./index.html#true">true</a> if the single argument is a <br>refinement, otherwise <a href="./index.html#false">false</a>. <br><br>Note that the argument is not checked against all existing refinements, <br>merely that it fits the syntax for a refinement.<br><br>The single argument can be of any type.<br></pre>例子<pre>red>> refinement? /all<br>true<br><br>red>> refinement? /nonsense<br>true<br><br>red>> refinement? /123<br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Invalid: string is not a refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> refinement? "/abc"<br>false<br><br>red>> r: "/abc"<br>"/abc"<br><br>red>> refinement? r<br>false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Valid: a refinement can be stored in a variable</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> r: /abc<br>== /abc<br><br>red>> refinement? r<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="reflect"> reflect</span> type: action! Categories: <a href="./index.html#cat-r01">反射</a><br><pre>Returns internal details about a value via reflection. <br><br>Arguments<br><br>value - of a type that supports reflection<br>field - a <a href="./index.html#wordxex">word!</a> such as spec, body, words, etc. Each <a href="./index.html#datatypexex">datatype!</a> <br> defines its own reflectors.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; reflect with a map: 'body, 'values</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> m: make map![a 1 b 2]<br>red>> reflect m 'body<br>== [a: 1 b: 2]<br><br>red>> reflect m 'values<br>== [1 2]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; reflect with object: 'body 'values 'words </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> place: make object! [<br> x-pos: 100<br> y-pos: 200<br>]<br><br>red>> reflect place 'body<br>== [x-pos: 100 y-pos: 200]<br><br>red>> reflect place 'values<br>== [100 200]<br><br>red>> reflect place 'words<br>== [x-pos y-pos]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="remainder"> remainder</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#remainder">remainder</a> returns the rest of dividing the first by the second value.<br><br>Has 2 arguments of type:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br>It is the functional version of the infix word <a href="./index.html#xslxsl">//</a>.<br><br>If the first argument is positive, then the remainder is positive.<br><br>If the first argument is negative, then the remainder is negative,<br>as in remainder -5 4, which results in -1.<br><br>If the first argument is zero, then the remainder is also zero.<br><br>If the second argument is zero, a run-time error occurs.<br></pre>例子<pre>red>> remainder 5 4<br>== 1<br><br>red>> remainder 5 5<br>== 0<br><br>red>> remainder 5 6<br>== 5<br><b style="color: green">; 5 divided by 6 gives zero</b><br><b style="color: green">; with remainder of 5</b><br><br>red>> remainder -5 4<br>== -1<br><br>red>> remainder 10 3.3<br>== 0.1000000000000005<br><br>red>> remainder 5x10 4<br>== 1x2<br><br>red>> remainder make vector![5 5 10] 4<br>== make vector! [1 1 2]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="remove"> remove</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#remove">remove</a> removes the first value(s) from a <a href="./index.html#seriesxex">series!</a><br>and returns the modified <a href="./index.html#seriesxex">series!</a> from the removal point onwards.<br><br>The single argument can be of type: <br> <a href="./index.html#seriesxex">series!</a> <br> <a href="./index.html#bitsetxex">bitset!</a> <br> <a href="./index.html#nonexex">none!</a><br><br>Refinements<br> /part - removes a number of values, or values up to the <br> given index.<br> This refinement requires one of:<br> <a href="./index.html#numberxex">number!</a> <br> <a href="./index.html#charxex">char!</a> <br> <a href="./index.html#seriesxex">series!</a><br><br>Note that for a <a href="./index.html#bitsetxex">bitset!</a> argument, the /part refinement is required.<br><br>Note that <a href="./index.html#remove">remove</a> is destructive. It changes the <a href="./index.html#seriesxex">series!</a> involved!!<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Setup 2 variables to be used in the examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> data: [22 11 44 66 10]<br>== [22 11 44 66 10]<br><br>red>> s: "abcdefg"<br>== "abcdefg"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Remove first item of a <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> remove data<br>== [11 44 66 10]<br><br>red>> data<br>== [11 44 66 10]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Remove first item of a <a href="./index.html#stringxex">string!</a> </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> remove s<br>== "bcdefg"<br><br>red>> s<br>== "bcdefg"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Remove the first 2 items using /part</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> remove/part data 2<br>== [66 10]<br><br>red>> data<br>== [66 10]<br><br>red>> remove/part s 2<br>== "defg"<br><br>red>> s<br>== "defg"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Bitset (E.g. hex code for "A" is 65, so the 65th bit is set)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: make bitset![#"A" #"N"]<br>make bitset! #{00000000000000004002}<br><br>red>> remove/part b #"N"<br>make bitset! #{00000000000000004000}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use /part with a <a href="./index.html#seriesxex">series!</a> index</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> nums: [1 2 3 4 5 6 7 8]<br>== [1 2 3 4 5 6 7 8]<br><br>red>> ref: skip nums 4<br>== [5 6 7 8]<br><br>red>> remove/part nums ref<br>== [5 6 7 8]<br><br>red>> nums<br>== [5 6 7 8]<br><br>red>> ref<br>== []<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="remove-each"> remove-each</span> type: native! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>Removes one or more values from a <a href="./index.html#seriesxex">series!</a>. <br>A block is evaluated for each element, and the element is removed<br>if the block is <a href="./index.html#true">true</a>. The original series is modified.<br><br>Arguments<br><br>word - a <a href="./index.html#wordxex">word!</a> or <a href="./index.html#blockxex">block!</a> of words to set. <br> These are used in the evaluation. They are not local.<br><br>data - a <a href="./index.html#seriesxex">series!</a>, which includes <a href="./index.html#stringxex">string!</a><br><br>body - a <a href="./index.html#blockxex">block!</a> to be evaluated.<br><br></pre>例子<pre>;remove-each, with only one 'word' argument<br>;make a series s to work with<br>red>> s: [3 6 "text" 12 15 "end"]<br><br>;remove each string element<br>red>> remove-each this-item s [string? this-item]<br>;note the modified series<br>red>> s<br>== [3 6 12 15]<br><br>;remove each item > 6<br>red>> remove-each this-item s [this-item > 6]<br>;note modified series<br>red>> s<br>== [3 6]<br><br>;a string of characters - remove all spaces<br>red>> text: "a few words with spaces"<br>red>> remove-each ch text [ch = #" "]<br>;check the result<br>red>> text<br>== "afewwordswithspaces"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="repeat"> repeat</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#repeat">repeat</a> evaluates a given <a href="./index.html#blockxex">block!</a> a specified number of times <br>and exposes the count value to the <a href="./index.html#blockxex">block!</a> being executed.<br><br>Has 3 parameters:<br> 1. name of a count variable, which contains the current value of the counter<br> 2. number of times the <a href="./index.html#blockxex">block!</a> should be evaluated<br> 3. the <a href="./index.html#blockxex">block!</a> to be evaluated<br><br>Warning:<br> 1. the count variable can only be referred within the <a href="./index.html#blockxex">block!</a>;<br> so, if before the repeat a variable exists with the same name,<br> that variable will be untouched after <a href="./index.html#repeat">repeat</a><br> 2. when repeat introduces a unique name for count, that name<br> cannot be referenced anymore after <a href="./index.html#repeat">repeat</a><br></pre>例子<pre>counter: 33<br>== 33<br>repeat counter 4 [print ["Evaluation #" counter]]<br><b style="color: blue">Evaluation # 1</b><br><b style="color: blue">Evaluation # 2</b><br><b style="color: blue">Evaluation # 3</b><br><b style="color: blue">Evaluation # 4</b><br>>> counter<br>== 33<br><br>repeat x 3 [print ["Evaluation #" x]]<br><b style="color: blue">Evaluation # 1</b><br><b style="color: blue">Evaluation # 2</b><br><b style="color: blue">Evaluation # 3</b><br>>> x<br>** Script Error: x has no value<br>** Near: x<br><br>repeat y 5 [y: y - 1 print ["y =" y]]<br><b style="color: blue">y = 0</b><br><b style="color: blue">y = 1</b><br><b style="color: blue">y = 2</b><br><b style="color: blue">y = 3</b><br><b style="color: blue">y = 4</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="repend"> repend</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>Appends a reduced value to a series and returns the series head. <br>The original series is modified.<br><br>Arguments<br> - a <a href="./index.html#seriesxex">series!</a><br> - a value to be appended, of any type.<br><br>Refinements<br> /only - Appends a block value as a block.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; repend a block - note the evaluation</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;make a series to work with<br>red>> s: [10 "eleven" 12]<br><br>red>> repend s [7 + 7 "fifteen"]<br>== [10 "eleven" 12 14 "fifteen"]<br>;s has changed<br>red>> s<br>== [10 "eleven" 12 14 "fifteen"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /only refinement - note nested block</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> repend/only s [7 + 7 "fifteen"]<br>== [10 "eleven" 12 14 "fifteen" [14 "fifteen"]]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="replace"> replace</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#replace">replace</a> replaces the search-value with the replace value <br>in a <a href="./index.html#seriesxex">series!</a>. <br><br>It can be used with strings, because a <a href="./index.html#stringxex">string!</a> is a <a href="./index.html#seriesxex">series!</a>.<br><br>It has 3 arguments: <br> series - the <a href="./index.html#seriesxex">series!</a> to be modified.<br> search-value - the value to be replaced (any type)<br> replace-value - the value to replace with (any type)<br><br>The search is case-insensitive and only the first occurrence is replaced, <br>unless the refinement /all is used. <br><br>The replaced and replacing item can have a different length.<br><br>Refinements<br> /all - replace all occurrences<br><br>Note that this is a destructive operation. It alters the <a href="./index.html#seriesxex">series!</a><br>involved!<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Replace a by W</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> s: "abcde"<br>"abcde"<br><br>red>> replace s "a" "W"<br>"Wbcde"<br><br>red>> s<br>"Wbcde"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Note the case insensitivity here</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> a-string: "The cat and the dog"<br>"The cat and the dog"<br><br>red>> replace a-string "the" "a"<br>"a cat and the dog"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using the /all refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> river: "Mississippi"<br>"Mississippi"<br><br>red>> replace/all river "is" "IS"<br>"MISsISsippi"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A series of numbers</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>red>> nums: [21 22 23 -1 44 45 46]<br>[21 22 23 -1 44 45 46]<br><br>red>> replace nums -1 [33 34 35]<br>[21 22 23 33 34 35 44 45 46]<br><br>red>> replace nums [21 22 23] -1<br>[-1 33 34 35 44 45 46]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="request-dir"> request-dir</span> type: native! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>Causes a dialog to appear asking the user to select a directory, and returns<br>the full directory path as a <a href="./index.html#filexex">file!</a> type, or a block of paths. <br>It returns <a href="./index.html#none">none</a> if no selection is made. The title bar shows:<br> 'Browse For Folder' <br>It works in a Red GUI program, and also in a non-GUI console program.<br> <br>There are no arguments.<br><br>Refinements<br> /title - to be displayed under the title bar. We provide a <a href="./index.html#stringxex">string!</a><br><br> /dir - Set starting directory. We provide a name, which can be a <br> <a href="./index.html#stringxex">string!</a> or <a href="./index.html#filexex">file!</a>.<br><br> /filter - To Be Developed: Block of filters (filter-name filter):<br> a <a href="./index.html#blockxex">block!</a><br><br> /keep - Keep previous directory path<br><br> /multi - To Be Developed: Allows multiple file selection, returned as<br> a block.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use request-dir from the Red console, on Windows</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> choice: request-dir<br>;user browsed to c:\mike\ALBUM\ Note the %, indicating a file! <br>red>> choice<br>== %/C/ALBUM/<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /dir and /title refinements</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;add a title, and start with C:/mike selected<br>red>> print request-dir/title/dir "Choose Dir" "C:\mike"<br>== %/C/Mike/data/<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="request-file"> request-file</span> type: native! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>Causes a dialog to appear asking the user to select a file, and <br>returns the full file path as a <a href="./index.html#filexex">file!</a> type, or block of paths.<br>It returns <a href="./index.html#none">none</a> if no selection is made. 'Open' is displayed <br>as the default title. It works in a Red GUI app, and also in a<br> non-GUI console app.<br> <br>There are no arguments<br><br>Refinements<br> /title - window title. We supply a <a href="./index.html#stringxex">string!</a><br><br> /file - Default file name or directory. We supply a name as<br> a <a href="./index.html#stringxex">string!</a> or <a href="./index.html#filexex">file!</a>.<br><br> /filter - supply a block of filters consisting of pairs of filter<br> names, and the actual filters.<br><br> /save - File save mode.<br><br> /multi - Allows multiple file selection, returned as a block.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; request-file examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;display an 'open' dialog, on Windows<br>red>> choice: request-file<br>;note the file! type result<br>red>> choice<br>== %/C/red/try-demos.red<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /filter refinement .jpg, .red</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print request-file/filter ["jpegs" "*.jpg" "Red files" "*.red"]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="request-font"> request-font</span> type: unset! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>Causes a dialog to appear asking the user to select a font, and returns<br>a <a href="./index.html#fontxex">font!</a> <a href="./index.html#objectxex">object!</a>, or <a href="./index.html#none">none</a> if no selection is made. <br>It works in a Red GUI program, and also in a non-GUI console program.<br> <br>There are no arguments<br><br>Refinements<br><br> /mono - Show monospaced font only.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; request-font examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;display the dialog. The Dayton font is selected by the user here<br>red>> choice: request-font<br> <br>;note the result<br>red>> print choice<br>name: "Dayton"<br>size: 11<br>style: none<br>angle: 0<br>color: none<br>anti-alias?: false<br>shadow: none<br>state: none<br>parent: none<br><br>;and it is an object<br>red>> type? choice<br>== object!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="return"> return</span> type: native! Categories: <a href="./index.html#cat-e03">退出</a><br><pre>关键字 <a href="./index.html#return">return</a> returns a value from a <a href="./index.html#function">function</a>. <br>It needs one argument, of any type.<br><br>In <a href="./index.html#function">function</a>s which don't have a return value, you can use the word <a href="./index.html#exit">exit</a>.<br><br>Under special conditions it is useful to <a href="./index.html#return">return</a> the value <a href="./index.html#none">none</a>.<br><br>The value of a <a href="./index.html#blockxex">block!</a> is the value of last evaluation that takes place in it,<br>so this can be used to <a href="./index.html#return">return</a> a value, without using the <a href="./index.html#return">return</a> word.<br><br>If we want to <a href="./index.html#return">return</a> a value partway through a <a href="./index.html#blockxex">block!</a>, or want to make it <br>more explicit for a reader of the code, we also can use <a href="./index.html#return">return</a>.<br></pre>例子<pre>bigger: func [a b] [<br> either a > b [<br> return a<br> ][<br> return b<br> ]<br>]<br>print bigger 8 6<br><b style="color: blue">8</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="reverse"> reverse</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#reverse">reverse</a> reverses the order of elements in its argument. <br>The argument will be changed. Returns at the same position in the argument.<br><br>The argument can be a: <br> <a href="./index.html#seriesxex">series!</a> <br> <a href="./index.html#pairxex">pair!</a> <br> <a href="./index.html#tuplexex">tuple!</a><br><br>Refinements<br> /part - limits to a given length or position (<a href="./index.html#numberxex">number!</a> <a href="./index.html#seriesxex">series!</a>)<br> <br>Note:<br> - for <a href="./index.html#seriesxex">series!</a> <a href="./index.html#reverse">reverse</a> is destructive<br> - but not for <a href="./index.html#tuplexex">tuple!</a> and <a href="./index.html#pairxex">pair!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reverse a <a href="./index.html#blockxex">block!</a> <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [1 2 3 4]<br>== [1 2 3 4]<br><br>red>> reverse b<br>== [4 3 2 1]<br><br>red>> b<br>== [4 3 2 1]<br><br>red>> s: "ABCD"<br>== "ABCD"<br><br>red>> reverse s<br>== "DCBA"<br><br>red>> s<br>== "DCBA"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reverse a section of a <a href="./index.html#stringxex">string!</a> <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> words: "The black cat"<br>== "The black cat"<br><br>red>> reverse find words "cat"<br>== "tac"<br><br>red>> words<br>== "The black tac"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use refinement /part - reverse first 3</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: "abcdefg"<br>== "abcdefg"<br><br>red>> reverse/part s 3<br>== "cbadefg"<br><br>red>> s<br>== "cbadefg"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reverse all values before value 50</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b: [10 20 30 40 50 60 70]<br>== [10 20 30 40 50 60 70]<br><br>red>> reverse/part b find b 50<br>== [40 30 20 10 50 60 70]<br><br>red>> b<br>== [40 30 20 10 50 60 70]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reverse a tuple - note unchanged value of t afterwards!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t: 11.22.33.44.55<br>== 11.22.33.44.55<br><br>red>> reverse t<br>== 55.44.33.22.11<br><br>red>> t<br>== 11.22.33.44.55<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Reverse a pair - note unchanged value of p afterwards!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> p: 100x200<br>== 100x200<br><br>red>> reverse p<br>== 200x100<br><br>red>> p<br>== 100x200<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="round"> round</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>Returns the nearest integer value. Halves round up (away from zero) by<br>default. Note that refinements allow decimal places (etc) to be specified.<br><br>Arguments<br>The single argument can be a <a href="./index.html#numberxex">number!</a> or a <a href="./index.html#timexex">time!</a><br><br>Refinements<br> /to - Return the nearest multiple of the scale parameter.<br> We supply a non-zero <a href="./index.html#numberxex">number!</a><br> /even - Halves round toward even results.<br> /down - Round toward zero, ignoring discarded digits - i.e. truncate.<br> /half-down - Halves round toward zero, not away from zero.<br> /floor - Round in negative direction.<br> /ceiling - Round in positive direction.<br> /half-ceiling - Halves round in positive direction.<br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; round - no refinements</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;basic use<br>red>> round 2.3<br>== 2.0<br><br>;note -ve - round toward zero<br>red>> round -3.3<br>== -3.0<br><br>;halves round away from zero<br>red>> round 2.5<br>== 3.0<br>red>> round -3.5<br>== -4.0<br><br>;time argument - note rounded seconds<br>red>> round 13:14:15.6<br>== 13:14:16<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /to refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/to 12.36 0.1<br>== 12.4<br>red>> round/to 2888 100<br>== 2900<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /even refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;towards even: 4 not 5<br>red>> round/even 4.5<br>== 4.0<br>;towards even: 4 not 3<br>red>> round 3.5<br>== 4.0<br>red>> round 4.5<br>== 5.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /down refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/down 3.9<br>== 3.0<br>red>> round/down -3.9<br>== -3.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /half-down refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/half-down 2.5<br>== 2.0<br>red>> round/half-down -3.5<br>== -3.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /floor refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/floor 3.9<br>== 3.0<br>red>> round/floor -3.9<br>== -4.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /ceiling refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/ceiling 3.2<br>== 4.0<br>red>> round/ceiling -3.9<br>== -3.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /half-ceiling refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> round/half-ceiling 3.5<br>== 4.0<br>red>> round/half-ceiling -3.5<br>== -3.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="routine"> routine</span> type: function! Categories: <a href="./index.html#cat-f03">函数</a>, <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="routinexex"> routine!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a>, <a href="./index.html#cat-f03">函数</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#routinexex">routine!</a> is used to link up to external code. <br><br>Once a library has been loaded, it is possible to create a <a href="./index.html#routinexex">routine!</a> <br>type to access the external function from Red. <br><br>You can use <a href="./index.html#make">make</a> to create a new, named <a href="./index.html#routinexex">routine!</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use <a href="./index.html#make">make</a> to create a <a href="./index.html#routinexex">routine!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><b style="color: green">; red-routine-name: make routine! specs library-name func-id</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Docs to be extended by red-by-example team ...</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="routinexqm"> routine?</span> type: function! Categories: <a href="./index.html#cat-f03">函数</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#routinexqm">routine?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#routinexex">routine!</a>,<br>otherwise <a href="./index.html#false">false</a>.<br><br>A <a href="./index.html#routinexex">routine!</a> is a function in an external library.<br><br>Its single argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; 关键字 <a href="./index.html#cos">cos</a> is external</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> routine? :cos <b style="color: green">; Note the colon!</b><br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; 关键字 <a href="./index.html#sort">sort</a> is not in an external library</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> routine? :sort<br>false<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="samexqm"> same?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a>, <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#samexqm">same?</a> returns <a href="./index.html#true">true</a> if the arguments refer to <br>identical objects, otherwise <a href="./index.html#false">false</a>. <br><br>For example, <a href="./index.html#true">true</a> would be returned if two strings are the <br>same string (that is: they occupy the same memory location). <br><br>The two arguments can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Same string, but in differnet memory locations</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a: "fish"<br> "fish"<br><br>red>> b: "fish"<br>"fish"<br><br>red>> same? a b<br>false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Same string and same memory location</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a: "meat"<br>"meat"<br><br>red>> b: a<br>"meat"<br><br>red>> same? a b<br>true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="save"> save</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#save">save</a> is used to save Red code to a <a href="./index.html#filexex">file!</a>, <a href="./index.html#urlxex">url!</a>, <br><a href="./index.html#binaryxex">binary!</a> or <a href="./index.html#stringxex">string!</a>. <br><br>The <a href="./index.html#load">load</a> word is intended for reading back items created with <a href="./index.html#save">save</a>.<br>Note that <a href="./index.html#write">write</a> is intended for storing data, not code.<br><br>Red uses brackets [ ] { } and quotes " " etc. to enclose data items. <br>The items might or might not be code. In a sense they become code when <br>we instruct Red to interpret them. Because of this, <a href="./index.html#save">save</a> can be <br>used to save data as well as code. In fact, there is no difference.<br>Red has the same adagium as Lisp: <b style="color: green">; Code = Data</b>.<br><br>关键字 <a href="./index.html#save">save</a> has 2 arguments:<br> where to save - one of <br> <a href="./index.html#filexex">file!</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#binaryxex">binary!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#nonexex">none!</a><br> value - the value(s) to save<br><br>Refinements:<br> /header - provide a Red header block (or output non-code datatypes). <br> This requires header-data (a <a href="./index.html#blockxex">block!</a>) or an <a href="./index.html#objectxex">object!</a><br> /all - save in serialized format. (Not available yet)<br> /length - save the length of the script content in the header<br> /as - specify the format of data; use NONE to save as plain text;<br> format [word! none!] => E.g. json, html, jpeg, png, redbin etc.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Save 2 lines of code in a file mydata.r</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> code: [<br>[ print "Hello"<br>[ print "Goodbye"<br>[ ]<br>== [<br> print "Hello" <br> print "Goodbye"<br>]<br><br>red>> save %mydata.r code<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Load the just saved data back</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> load %mydata.r<br>[print "Hello" <br> print "Goodbye"<br>]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; We can use do to interpret the code in the file</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> do %mydata.r<br><b style="color: blue">Hello</b><br><b style="color: blue">Goodbye</b><br><br>red>> do code<br><b style="color: blue">Hello</b><br><b style="color: blue">Goodbye</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Save some structured data</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> data: [ [1 10] [2 20] 30]<br>== [[1 10] [2 20] 30]<br><br>red>> save %mydata.r data<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Load that data back</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> load %mydata.r<br>== [[1 10] [2 20] 30]<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="second"> second</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#second">second</a> returns the second value of a <a href="./index.html#seriesxex">series!</a>. <br><br>The argument can be one of:<br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#pairxex">pair!</a><br><br>If there is no second item in the <a href="./index.html#seriesxex">series!</a>, <a href="./index.html#none">none</a> is returned.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Second of a <a href="./index.html#blockxex">block!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> second [3 4 5]<br>4<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Second of a <a href="./index.html#stringxex">string!</a> (a <a href="./index.html#charxex">char!</a>)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> second "ABC"<br>#"B"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#seriesxex">series!</a> having no second element</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> second [44]<br>none<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Second of a <a href="./index.html#tuplexex">tuple!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> second 66.77.88<br>77<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Second of a <a href="./index.html#pairxex">pair!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> second 22x55<br>55<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="select"> select</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#select">select</a> finds a value in a <a href="./index.html#seriesxex">series!</a> and if succesful returns <br>the element right after the element found. Returns <a href="./index.html#none">none</a> if the search fails.<br><br>Select is similar to the <a href="./index.html#find">find</a>函数。 <br><br>The 2 arguments are:<br> a series - of type <a href="./index.html#seriesxex">series!</a> <a href="./index.html#any-objectxex">any-object!</a> <a href="./index.html#mapxex">map!</a> <a href="./index.html#nonexex">none!</a><br> a value - of any type <br><br>Refinements<br> /part - Limit the length (a <a href="./index.html#numberxex">number!</a>) of the search or a <a href="./index.html#seriesxex">series!</a> reference.<br> /only - Treat a series search value as a single value.<br> /case - Perform a case-sensitive search.<br> /any - Use * and ? wildcards in string searches.<br> /with - Use custom wildcards * or ?.<br> /skip - Treat the series as fixed size records. Requires an <a href="./index.html#integerxex">integer!</a> size.<br> /last - Find the last occurrence of value (from the <a href="./index.html#tail">tail</a>).<br> /reverse - Find the last occurrence of value (from the current index).<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Select a month, return item following it</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> months: ["Mar" 31 "April" 30 "May" 31]<br>== ["Mar" 31 "April" 30 "May" 31]<br><br>red>> select Months "April"<br>== 30<br><br>red>> select Months 30<br>== "May" <b style="color: green">; Beware that select can match any element!</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Select a character in a <a href="./index.html#stringxex">string!</a> (after D)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: "ABCDEFGH"<br>== "ABCDEFGH"<br><br>red>> select str "D"<br>== #"E" <b style="color: green">; Because E follows the found element D</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /pairs - do a normal select, then use /pairs</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> pairs: [44 4 3 33 4 55]<br>== [44 4 3 33 4 55]<br><br>red>> select pairs 4<br>== 3 <b style="color: green">; Because 3 follows the found element 4</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Select only matches the first element in a skip group</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> select/skip pairs 4 2<br>== 55<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Search form the tail</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> animal: "The black cat"<br>== "The black cat"<br><br>red>> select/last animal "a"<br>== #"t"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using the /only refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> blk: [11 12 13 [22 33 44] 15]<br>== [11 12 13 [22 33 44] 15]<br><br>red>> select blk 13<br>== [22 33 44]<br> <br>red>> select blk [22 33 44]<br>== none <b style="color: green">; Not found, because we searched for a <a href="./index.html#seriesxex">series!</a></b><br> <br>red>> select/only blk [22 33 44]<br>15 <br><br>red>> select/only blk [22 33 44]<br>== 15 <b style="color: green">; Success! With /only we can search for a <a href="./index.html#seriesxex">series!</a></b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Search backwards from a position with the /reverse refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> words: "a-few-words"<br>== "a-few-words"<br> <br>red>> current: find/last words "-"<br>"-words"<br><br>red>> current: find/last words "-"<br>== "-words"<br><br>red>> index? current<br>== 6<br><br>red>> select/reverse current "-"<br>== #"f"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="seriesxex"> series!</span> type: typeset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#seriesxex">series!</a> is a <a href="./index.html#typesetxex">typeset!</a> containing several <a href="./index.html#datatypexex">datatype!</a>s.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show all <a href="./index.html#seriesxex">series!</a> types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ? series!<br>series! is a typeset! of value: <br> make typeset! [<br> block! <br> paren! <br> string! <br> file! <br> url! <br> path! <br> lit-path! <br> set-path! <br> get-path! <br> vector! <br> hash! <br> binary! <br> image!<br> ]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="seriesxqm"> series?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>word <a href="./index.html#seriesxqm">series?</a> returns <a href="./index.html#true">true</a> if its argument is a<br><a href="./index.html#seriesxex">series!</a>, otherwise <a href="./index.html#false">false</a>.<br><br>The argument can be of any type.<br><br>The <a href="./index.html#seriesxex">series!</a> type includes: <br> <a href="./index.html#blockxex">block!</a> <br> <a href="./index.html#parenxex">paren!</a> <br> <a href="./index.html#stringxex">string!</a> <br> <a href="./index.html#filexex">file!</a> <br> <a href="./index.html#urlxex">url!</a> <br> <a href="./index.html#pathxex">path!</a> <br> <a href="./index.html#lit-pathxex">lit-path!</a> <br> <a href="./index.html#set-pathxex">set-path!</a> <br> <a href="./index.html#get-pathxex">get-path!</a> <br> <a href="./index.html#vectorxex">vector!</a> <br> <a href="./index.html#hashxex">hash!</a> <br> <a href="./index.html#binaryxex">binary!</a> <br> <a href="./index.html#imagexex">image!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#blockxex">block!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series? [1 "text"]<br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#tuplexex">tuple!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series? 12.33.12<br>false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series? "ABC"<br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A <a href="./index.html#floatxex">float!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> series? 12.34<br>false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="set"> set</span> type: native! Categories: <a href="./index.html#cat-w01">标识符操作</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="set-current-dir"> set-current-dir</span> type: routine! Categories: <a href="./index.html#cat-f01">文件</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="set-env"> set-env</span> type: native! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="set-pathxex"> set-path!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>A <a href="./index.html#set-pathxex">set-path!</a> is a kind of <a href="./index.html#pathxex">path!</a> used to change (set) a value. Refer <br>to <a href="./index.html#pathxex">path!</a> and <a href="./index.html#set-wordxex">set-word!</a> for more details.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a set-path!, and check the type.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> b:[11 22 33 44]<br><br>;note the trailing colon<br>red>> b/2: -999<br>== -999<br>;note the changed value<br>red>> b<br>== [11 -999 33 44]<br>;now with a variable<br>red>> place: 3<br>== 3<br>;the first : gets the value of place, second makes a set-path!<br>red>> b/:place: -1000<br>== -1000<br>red>> b<br>== [11 -999 -1000 44]<br><br>;Find the type - first [block] is used to prevent evaluation<br>red>> type? first [b/:place:]<br>== set-path!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="set-pathxqm"> set-path?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>This word returns true if its argument is a <a href="./index.html#set-pathxex">set-path!</a> type, otherwise false.<br><br>Its single argument can be any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; use set-path? on various types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;create a block and position to work with<br>red>> b: [11 22 33]<br>red>> n: 2<br><br>;get-path? with an evaluated path<br>red>> set-path? b/2:<br>*** Script Error: b/2: needs a value<br>*** Where: set-path?<br><br>;now use first [ block ] to prevent evaluation<br>red>> set-path? first [b/2:]<br>== true<br>red>> set-path? first [b/:n:]<br>== true<br>;this is a path!<br>red>> set-path? first [b/n]<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="set-quiet"> set-quiet</span> type: routine! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="set-wordxex"> set-word!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>Red has a notation which modifies how a word is evaluated. The colon and <br>single quote mark ('tick') are used. For example, for a word w, we have:<br><br> w - sets the word to a value. Its type is <a href="./index.html#set-wordxex">set-word!</a><br> :w - gets the word's value, but does not evaluate it. Its type is <br> <a href="./index.html#get-wordxex">get-word!</a><br> 'w - treat the word as a symbol, with no evaluation. Its type is <br> <a href="./index.html#lit-wordxex">lit-word!</a> (i.e. literal word).<br> w - normal evaluation. If the word is a function, evaluate it.<br><br>Note that : and ' are not functions. Attaching them to a word changes the <br>type of the word, and how it is used.<br><br>We can use the <a href="./index.html#set-wordxqm">set-word?</a> , <a href="./index.html#get-wordxqm">get-word?</a>, <a href="./index.html#lit-wordxqm">lit-word?</a> functions to <br>test whether a word is one of these types.<br><br>The <a href="./index.html#set-wordxex">set-word!</a> type sets a word to a value. It is tempting for beginners <br>to assume that a colon is like an assignment operator in other languages, but <br>this is not the case. It specifies the use of a set-word! type, which expects <br>a value.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use a set-word! type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;provide a value<br>red>> a-word: 123<br><br>;a-word set to 999, then w set to a-word's value, 999<br>red>> w: a-word: 999<br><br>;the type of an unevaluated set-word<br>red>> type? first [ a: ]<br>== set-word!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="set-wordxqm"> set-word?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>Returns true if its argument is a <a href="./index.html#set-wordxex">set-word!</a> type, otherwise false.<br><br>Its single argument can be of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; A few types of argument</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> a-word: 123<br><br>;just a normal word <br>red>> set-word? a-word<br>== false<br><br>;correct set-word! syntax, but its value is not a reference<br>red>> set-word? a-word:<br>*** Script Error: a-word: needs a value<br>*** Where: a-word<br><br>;prevent evaluation with first [block]<br>red>> set-word? first [a-word:]<br>== true<br><br>;a get-word!<br>red>> set-word? first [:a-word]<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="shift"> shift</span> type: native! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#shift">shift</a> performs an arithmetical bit shift operation, <br>preserving the sign. <br><br>By default it shifts to the right, but left shifting is also possible.<br><br>A single right <a href="./index.html#shift">shift</a> divides by 2.<br>A single left <a href="./index.html#shift">shift</a> multiplies by 2.<br><br>Also logical shifting is possible.<br><br>It has 2 arguments:<br> - an <a href="./index.html#integerxex">integer!</a> to be shifted<br> - an <a href="./index.html#integerxex">integer!</a> stating how many places to shift<br> <br>Note: the infix <a href="./index.html#xltxlt"><<</a> <a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> operators provide similar facilities.<br><br>Refinements<br> /left - shift bits to the left instead of to the right<br> /logical - use logical shift (unsigned, fill with zeroes)<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Right-shift a positive number</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift 64 2<br>== 16<br><br>red>> to-hex 64<br>== #00000040<br><br>red>> to-hex 16<br>== #00000010<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Right-shift a negative number, preserving sign</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift -1 4<br>== -1<br><br>red>> to-hex -1<br>== #FFFFFFFF <b style="color: green">; Left most bit stays 1 (= negative)</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Left-shift a positive number</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift/left 64 2<br>== 256<br><br>red>> to-hex 64<br>== #00000040<br><br>red>> to-hex 256<br>== #00000100<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Left-shift a negative number, preserving sign</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift/left -1 4<br>== -16<br><br>red>> to-hex -1<br>== #FFFFFFFF<br><br>red>> to-hex -16<br>== #FFFFFFF0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Logical right-shift, no sign preservation</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift/logical -1 4<br>== 268435455<br><br>red>> to-hex -1<br>== #FFFFFFFF<br><br>red>> to-hex 268435455<br>== #0FFFFFFF<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="shift-left"> shift-left</span> type: routine! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#shift-left">shift-left</a> performs a logical shift-left operation. <br>The sign-bit is not preserved.<br><br>A single <a href="./index.html#shift-left">shift-left</a> multiplies by 2.<br><br>It has 2 arguments:<br> - an <a href="./index.html#integerxex">integer!</a> value to be shifted<br> - an <a href="./index.html#integerxex">integer!</a> stating how many places to shift.<br><br>Note that the infix words <a href="./index.html#xltxlt"><<</a> <a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> provide similar <br> facilities.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Normal <a href="./index.html#shift-left">shift-left</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex 64<br>== #00000040<br><br>red>> shift-left 64 2<br>256<br><br>red>> to-hex shift-left 64 2<br>== #00000100<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sign bit changed by shift ...</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex 1<br>== #00000001<br><br>red>> to-hex shift-left 1 31<br>== #80000000 <b style="color: green">; Left most bit (sign bit) changed</b><br><br>red>> shift-left 1 31<br>== -2147483648 <b style="color: green">; See, it it negative!</b><br><br>red>> to-hex shift-left 1 32<br>== #00000001 <b style="color: green">; Wrapped around by 32 bits now</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="shift-logical"> shift-logical</span> type: routine! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#shift-logical">shift-logical</a> performs a logical right shift. <br>The sign is not preserved.<br><br>It has 2 arguments:<br> - an <a href="./index.html#integerxex">integer!</a> value to be shifted<br> - an <a href="./index.html#integerxex">integer!</a> stating how many bitss to shift<br><br>Note that the infix <a href="./index.html#xltxlt"><<</a> <a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> operators provide similar facilities.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Shift (right) by 2 bits</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex 64<br>== #00000040 <b style="color: green">; Last byte = binary 0100 0000</b><br><br>red>> shift-logical 64 2<br>== 16<br><br>red>> to-hex shift-logical 64 2<br>== #00000010 <b style="color: green">; Last byte = binary 0001 0000</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Shift (right) by 1 bit - note zero entering at the left</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex -1<br>== #FFFFFFFF <b style="color: green">; First byte = binary 1111 1111</b><br><br>red>> shift-logical -1 1<br>== 2147483647<br><br>red>> to-hex shift-logical -1 1<br>== #7FFFFFFF <b style="color: green">; First byte = binary 0111 1111</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="shift-right"> shift-right</span> type: routine! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#shift-right">shift-right</a> performs a right-shift operation.<br><br>A single <a href="./index.html#shift-right">shift-right</a> divides by 2.<br><br>It has 2 arguments:<br> - an <a href="./index.html#integerxex">integer!</a> value to be shifted<br> - an <a href="./index.html#integerxex">integer!</a> stating how many places to shift<br><br>Note that the infix <a href="./index.html#xltxlt"><<</a> <a href="./index.html#xgtxgt">>></a> <a href="./index.html#xgtxgtxgt">>>></a> operators provide <br> similar facilities.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Normal shift</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> shift-right 16 2<br>== 4<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Negative sign (left most bit) will be preserved</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>to-hex -2147483648<br>== #80000000 <b style="color: green">; #80 is binary 1000 0000</b><br><br>red>> shift-right -2147483648 1<br>== -1073741824<br><br>red>> to-hex -1073741824<br>== #C0000000 <b style="color: green">; #C0 is binary 1100 0000</b> <br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="sin"> sin</span> type: routine! <pre>This word is a synonym for <a href="./index.html#sine">sine</a></pre><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><span class="mike-large" id="sine"> sine</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#sine">sine</a> returns the trigonometric sine.<br><br>Has 1 parameter, a <a href="./index.html#numberxex">number!</a> (representing an angle).<br><br>Refinements:<br> /radians : expects the input angle in radians;<br> without refinement expects the input angle in degrees.<br></pre>例子<pre>sine 90<br>== 1.0<br><br>sine/radians pi<br>== 0.0<br><br>sine/radians pi + 0.003<br>== -0.002999995500002016<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="skip"> skip</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#skip">skip</a> moves the index of a <a href="./index.html#seriesxex">series!</a>.<br><br>Note: you can test the position of the index using <a href="./index.html#indexxqm">index?</a>.<br></pre>例子<pre>red>> x: [1 2 3 4 5 6 7 8 9]<br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> index? x<br>== 1<br><br>red>> skip x 3<br>== [4 5 6 7 8 9] <b style="color: green">; Skip does not change the target <a href="./index.html#seriesxex">series!</a></b><br><br>red>> x<br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> x: skip x 3<br>== [4 5 6 7 8 9]<br><br>red>> x<br>== [4 5 6 7 8 9]<br><br>red>> index? x<br>== 4 <b style="color: green">; Original position (1) + skip offset (3)</b><br><br>red>> x: skip x -1 <b style="color: green">; Skipping backward is allowed</b><br>== [3 4 5 6 7 8 9]<br><br>red>> x<br>== [3 4 5 6 7 8 9]<br><br>red>> index? x<br>== 3<br><br>red>> x: skip x 100 <b style="color: green">; Skip forward out of range moves to <a href="./index.html#tail">tail</a></b><br>== []<br><br>red>> index? x<br>== 10<br><br>red>> tail? x<br>== true<br><br>red>> x: skip x -100 <b style="color: green">; Skip backward out of range moves to <a href="./index.html#head">head</a></b><br>== [1 2 3 4 5 6 7 8 9]<br><br>red>> index? x<br>== 1<br><br>red>> head? x<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="sort"> sort</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#sort">sort</a> sorts a <a href="./index.html#seriesxex">series!</a>, modifying the original <a href="./index.html#seriesxex">series!</a>. <br><br>The default order is ascending and the sort is by default case-insensitive.<br><br>The argument must be a <a href="./index.html#seriesxex">series!</a> type:<br> - <a href="./index.html#blockxex">block!</a> <br> - <a href="./index.html#stringxex">string!</a> <br> - <a href="./index.html#vectorxex">vector!</a><br> etc.<br><br>Refinements<br> /case - perform a case-sensitive sort.<br> /reverse - reverse the sort order (descending instead of ascending)<br> /skip - treat the <a href="./index.html#seriesxex">series!</a> as fixed size records (groups of items). <br> Sorting is performed based on the value of the first item in <br> a group of items. The group size is specified as an <a href="./index.html#integerxex">integer!</a>. <br> /part - sort only part of a <a href="./index.html#seriesxex">series!</a>. <br> We provide a length (a <a href="./index.html#numberxex">number!</a>) or a position in the <a href="./index.html#seriesxex">series!</a><br> /compare - we specify a comparator, which can be an offset <a href="./index.html#integerxex">integer!</a>, <br> a <a href="./index.html#blockxex">block!</a> or a <a href="./index.html#functionxex">function!</a>.<br> /all - will force a group of items to be passed as a <a href="./index.html#seriesxex">series!</a> to <br> the compare function. You also will need /skip to specify the <br> size of such a group.<br> /stable - sort uses Quicksort as its default sorting algorithm. <br> Quicksort is very fast, but it is an unstable algorithm. <br> If you need stable sorting, add the /stable refinement, and it <br> will then use the Merge algorithm instead. <br> This issue is not significant for sorting simple <a href="./index.html#seriesxex">series!</a>.<br> <br>Read more about sort algorithms here: <br> <a href="https://en.wikipedia.org/wiki/Sorting_algorithm">Wikipedia on sort algorithm</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort some numbers ascending (changing the <a href="./index.html#seriesxex">series!</a> involved)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ages: [55 33 73 73 19]<br>== [55 33 73 73 19]<br><br>red>> sort ages<br>== [19 33 55 73 73]<br><br>red>> ages<br>== [19 33 55 73 73]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort some numbers descending</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ages: [55 33 73 73 19]<br>== [55 33 73 73 19]<br><br>red>> sort/reverse ages<br>== [73 73 55 33 19]<br><br>red>> ages<br>== [73 73 55 33 19]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort strings (case-insensitive sort)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> names: ["dog" "Ape" "Cat" "ant" "aardvark"]<br>== ["dog" "Ape" "Cat" "ant" "aardvark"]<br><br>red>> sort names<br>== ["aardvark" "ant" "Ape" "Cat" "dog"]<br><br>red>> names<br>== ["aardvark" "ant" "Ape" "Cat" "dog"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort strings (case-insensitive sort)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> names: ["dog" "Ape" "Cat" "ant" "aardvark"]<br>== ["dog" "Ape" "Cat" "ant" "aardvark"]<br><br>red>> sort/case names<br>== ["Ape" "Cat" "aardvark" "ant" "dog"]<br><br>red>> names<br>== ["Ape" "Cat" "aardvark" "ant" "dog"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort on the first item of each group of 2 items (the name)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> name-ages: ["Larry" 45 "Curly" 50 "Mo" 42]<br>== ["Larry" 45 "Curly" 50 "Mo" 42]<br><br>red>> sort/skip name-ages 2<br>== ["Curly" 50 "Larry" 45 "Mo" 42]<br><br>red>> name-ages<br>== ["Curly" 50 "Larry" 45 "Mo" 42]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort on a specific item (not the first which is default) of each group</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> name-ages: ["Larry" 45 "Curly" 50 "Mo" 42]<br>== ["Larry" 45 "Curly" 50 "Mo" 42]<br><br>red>> sort/skip/compare name-ages 2 2<br>== ["Mo" 42 "Larry" 45 "Curly" 50]<br><br>red>> name-ages<br>== ["Mo" 42 "Larry" 45 "Curly" 50]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort only a subset of the <a href="./index.html#seriesxex">series!</a> using a number</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [8 7 6 5 4 3 2]<br>== [8 7 6 5 4 3 2]<br><br>red>> sort/part s 3<br>== [6 7 8 5 4 3 2] <b style="color: green">; Only the first 3 items were sorted</b><br><br>red>> s<br>== [6 7 8 5 4 3 2]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Sort only a subset of the <a href="./index.html#seriesxex">series!</a> using a position</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> n: [9 8 7 6 5 4 3 2 1]<br>== [9 8 7 6 5 4 3 2 1]<br><br>red>> pos: skip n 4<br>== [5 4 3 2 1]<br><br>red>> sort/part n pos<br>== [6 7 8 9 5 4 3 2 1] <b style="color: green">; Only the first 4 items were sorted</b><br><br>red>> n<br>== [6 7 8 9 5 4 3 2 1]<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using /compare to specify a function to compare 2 items</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> names: ["Larry" "Curly" "Mo" ]<br>== ["Larry" "Curly" "Mo"]<br><br>red>> sort/compare names function [a b] [a > b]<br>== ["Mo" "Larry" "Curly"] <br><br>red>> names<br>== ["Mo" "Larry" "Curly"]<br><br>red>> sort/compare names function [a b] [a < b]<br>== ["Curly" "Larry" "Mo"]<br><br>red>> names<br>== ["Curly" "Larry" "Mo"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Specify which columns to compare using a path (e.g. /2)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> names2: ["Larry" 45 "Curly" 50 "Mo" 42]<br>== ["Larry" 45 "Curly" 50 "Mo" 42]<br><br>red>> sort/skip/compare/all name-ages 2 function [a b][a/2 > b/2]<br>== ["Curly" 50 "Larry" 45 "Mo" 42] <b style="color: green">; Sorted by descending age</b><br><br>red>> name-ages<br>== ["Curly" 50 "Larry" 45 "Mo" 42]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="source"> source</span> type: unset! Categories: <a href="./index.html#cat-d02">文档</a>, <a href="./index.html#cat-h01">帮助 & 调试</a><br><pre>关键字 <a href="./index.html#source">source</a> shows the source code of a mezzanine word. <br>Does not return a value.<br><br>A mezzanine word is a Red <a href="./index.html#wordxex">word!</a> that is defined in terms of Red itself.<br><br>Has 1 parameter, the name of an existing Red word,<br></pre>例子<pre>source join<br><b style="color: blue">join: func [</b><br><b style="color: blue"> "Concatenates values."</b><br><b style="color: blue"> value "Base value"</b><br><b style="color: blue"> rest "Value or block of values"</b><br><b style="color: blue">][</b><br><b style="color: blue"> value: either series? :value [copy value] [form :value]</b><br><b style="color: blue"> repend value :rest</b><br><b style="color: blue">]</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="space"> space</span> type: char! Categories: <a href="./index.html#cat-c05">常量</a><br><pre>关键字 <a href="./index.html#space">space</a> is a word which has the value space <a href="./index.html#charxex">char!</a> #" "<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use space</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> prin "A" prin space print "B"<br>A B<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="spec-of"> spec-of</span> type: function! Categories: <a href="./index.html#cat-r01">反射</a><br><pre>Returns the spec of a value that supports reflection. <br><br>Not currently implemented.<br><br>Arguments<br>A value of a type that supports reflection.<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="split"> split</span> type: function! Categories: <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#split">split</a> breaks a <a href="./index.html#stringxex">string!</a> into pieces using the provided delimiters. <br>A <a href="./index.html#blockxex">block!</a> is returned containing the individual pieces.<br><br>The arguments are:<br> a series - <a href="./index.html#any-stringxex">any-string!</a> - the string to be split.<br> a delimiter - <a href="./index.html#stringxex">string!</a> or <a href="./index.html#charxex">char!</a> - the delimiter <br> Note that the <a href="./index.html#charxex">char!</a> datatype has some common delimeters <br> predefined (such as 'newline', 'tab', 'space'. 'escape' etc.)<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Split with a space</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s1: "A few words"<br>== "A few words"<br><br>red>> split s1 " "<br>== ["A" "few" "" "" "" "" "" "words"]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use the predefined constant "space"</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> split s1 space<br>== ["A" "few" "" "" "" "" "" "words"]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="split-path"> split-path</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>Splits a <a href="./index.html#filexex">file!</a> or <a href="./index.html#urlxex">url!</a> path. Returns a block containing path and <br>target. <br><br>Arguments<br><br>A <a href="./index.html#filexex">file!</a> or a <a href="./index.html#urlxex">url!</a><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use split-path on a url, and a file</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> split-path http://www.red-lang.org/p/about.html<br>== [http://www.red-lang.org/p/ %about.html]<br><br>red>> split-path %data/personal/notes.txt<br>== [%data/personal/ %notes.txt]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="square-root"> square-root</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#square-root">square-root</a> returns the square-root of a <a href="./index.html#numberxex">number!</a>.<br><br>Its argument must be a <a href="./index.html#numberxex">number!</a> type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Square-root of <a href="./index.html#integerxex">integer!</a> gives a <a href="./index.html#floatxex">float!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> square-root 16<br>4.0<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Square-root of a <a href="./index.html#floatxex">float!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> square-root 4.1<br>2.024845673131658<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Square-root of a negative number (NaN = Not a Number)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> square-root -9<br>1.#NaN<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Square-root of a <a href="./index.html#pairxex">pair!</a> (invalid operation))</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> square-root 22x33<br>*** Script error: square-root does not allow pair! for its value argument<br>*** Where: square-root<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="stats"> stats</span> type: native! Categories: <a href="./index.html#cat-s05">系统相关</a><br><pre>关键字 <a href="./index.html#stats">stats</a> returns interpreter statistics, including <br>memory management data. <br><br>Refinements<br> /show - not yet implemented<br> /info - more detailed data<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Basic stats</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> stats<br>== 86605824<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; More detailed stats (Can be a large <a href="./index.html#blockxex">block!</a>, hence the ...)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print mold stats/info<br>== [[[9999 1 10000] [9999 1 10000] [9999 1 10000] [9999 1 10000] [...<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="strict-equalxqm"> strict-equal?</span> type: native! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#strict-equalxqm">strict-equal?</a> returns <a href="./index.html#true">true</a> if two values are equal<br>and are of the same <a href="./index.html#datatypexex">datatype!</a>, otherwise returns <a href="./index.html#false">false</a>.<br><br>When comparing strings lowercase is considered not equal to uppercase.<br></pre>例子<pre>red>> strict-equal? 12 12.0<br>== false<br><br>red>> strict-equal? "abc" "abc"<br>== true<br><br>red>> strict-equal? "abC" "ABC"<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="stringxex"> string!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#stringxex">string!</a> represents a <a href="./index.html#seriesxex">series!</a> type containing characters.<br>For string functions (such as substring etc), we use the series functions, <a href="./series.html"> here</a>.<br>(Awaiting additional documentation by red-by-example team.)<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Some examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: "abcdefg"<br>== "abcdefg"<br>;Using { } allows a string to spread over several lines - spaces and newlines are significant<br>red>> s: { a two-line<br> string}<br>red>> str/3<br>== #"c" <b style="color: green">; Representation of a single character in Red</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="stringxqm"> string?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#stringxqm">string?</a> returns <a href="./index.html#true">true</a> if its argument is<br>a <a href="./index.html#stringxex">string!</a>, otherwise <a href="./index.html#false">false</a>.<br><br>Its argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> string? "abc"<br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test a <a href="./index.html#charxex">char!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> string? #"A"<br>false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test a <a href="./index.html#numberxex">number!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> string? 12.34<br>false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="subtract"> subtract</span> type: action! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#subtract">subtract</a> subtracts the second value from the first.<br>It is equivalent of the infix operator <a href="./index.html#-">-</a>.<br><br>It has 2 arguments, which can be of these types:<br> <a href="./index.html#numberxex">number!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br></pre>例子<pre>red>> subtract 3.4 2<br>== 1.4<br><br>red>> v: make vector! [2 3 4]<br>== make vector! [2 3 4]<br><br>red>> v2: make vector! [10 100 200]<br>== make vector! [10 100 200]<br><br>red>> subtract v v2<br>== make vector! [-8 -97 -196]<br><br>red>> subtract 20x10 3x3<br>== 17x7<br><br>red>> subtract 10 3x3<br>*** Script error: subtract does not allow pair for its value2 argument<br>*** Where: subtract<br><br>red>> subtract 3x3 10<br>== -7x-7<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="suffixxqm"> suffix?</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#suffixxqm">suffix?</a> returns the extension of a <a href="./index.html#filexex">file!</a>, <br>the suffix of a <a href="./index.html#urlxex">url!</a>, otherwise returns <a href="./index.html#none">none</a>. <br><br>Note that when a suffix is found, a <a href="./index.html#filexex">file!</a> type is returned.<br><br>Its single argument can be:<br> <a href="./index.html#filexex">file!</a> <a href="./index.html#urlxex">url!</a> <a href="./index.html#stringxex">string!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; File with extension (The % is used in literal files)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> suffix? %myfile.txt<br>%.txt<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; File without extension</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> suffix? %myfile<br>none<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; URL with suffix</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> suffix? http://www.place.org/info.html<br>%.html<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; URL without suffix</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> suffix? http://www.google.com/<br>none<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; File with extension as a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> suffix? "data.txt"<br>%.txt<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="swap"> swap</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#swap">swap</a> swaps elements between two <a href="./index.html#seriesxex">series!</a> or the same <a href="./index.html#seriesxex">series!</a>. <br>It modifies both arguments.<br><br>The 2 arguments must be of type <a href="./index.html#seriesxex">series!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create 2 series to work with (different lengths)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s1: [1 2 3 4 5 6]<br>== [1 2 3 4 5 6]<br><br>red>> s2: [100 200 300 400]<br>== [100 200 300 400]<br><br>red>> swap s1 s2 <b style="color: green">; Swap first elements</b><br>== [100 2 3 4 5 6]<br><br>red>> s1<br>== [100 2 3 4 5 6] <b style="color: green">; s1 was changed</b><br><br>red>> s2<br>== [1 200 300 400] <b style="color: green">; s2 also changed</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Swap within same series; arg 1 is element 1; arg 2 is element 100</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ser: [ 1 2 3 4 5 100 200 300 400]<br>== [1 2 3 4 5 100 200 300 400]<br><br>red>> swap ser find ser 100<br>== [100 2 3 4 5 1 200 300 400]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Also <a href="./index.html#stringxex">string!</a>s are <a href="./index.html#seriesxex">series!</a>!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> swap "ABC" "xyz" <b style="color: green">; Swap first characters of each string</b><br>== "xBC"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Swap in the middle of some <a href="./index.html#seriesxex">series!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> sa: [22 11 33 55]<br>== [22 11 33 55]<br><br>red>> sb: [105 101 107 109]<br>== [105 101 107 109]<br><br>red>> swap find sa 33 find sb 101<br>== [101 55]<br><br>red>> sa<br>== [22 11 101 55]<br><br>red>> sb<br>== [105 33 107 109]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="switch"> switch</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a><br><pre>关键字 <a href="./index.html#switch">switch</a> chooses a <a href="./index.html#blockxex">block!</a> based on a value. <br><br>We provide a value (which can be an expression of any type), then a <br>series of <a href="./index.html#blockxex">block!</a>s, each prefixed with a value. <br><br>The block associated with the matching value is evaluated. <br>The prefixed values are not evaluated (Note that differing types are allowed).<br><br>The value of the last evaluation in the matched block is returned.<br><br>Refinements<br> /default - allows us to specify a default <a href="./index.html#blockxex">block!</a> at <br> the bottom of the <a href="./index.html#switch">switch</a>, which is executed<br> when no value matches<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; We try to match on different datatypes here</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>switch 23.77.44 [ <br> 1 [print "1: integer"]<br> 23.77.44 [print "23.77.44: a tuple"]<br> "India" [print "India: string"<br> country: true]<br>]<br><b style="color: blue">23.77.44: a tuple</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Using the /default refinement where nothing matches with "China"</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>item: "China"<br>switch/default item [ <br> 1 [print "1: integer"]<br> 23.77.44 [print "23.77.44: a tuple"]<br> "India" [print "India: string"<br> country: true]<br>] [<br> print "No match"<br>]<br><b style="color: blue">No match</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tagxex"> tag!</span> type: unset! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>This <a href="./index.html#datatypexex">datatype!</a> provides a literal way of expressing items enclosed<br>in '<' and '>'. It is a type of series. There are also the related <br><a href="./index.html#to-tag">to-tag</a> and <a href="./index.html#tagxqm">tag?</a> functions.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a tag! type, explore it.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>>> t: <picture 100 200><br>== <picture 100 200><br>; Examine its type<br>>> type? t<br>== tag!<br><br>; Tag as series:<br>>> first t<br>== #"p"<br>>> append t " square"<br>== <picture 100 200 square><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tagxqm"> tag?</span> type: unset! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>This function returns <a href="./index.html#true">true</a> if its argument is an <a href="./index.html#tagxex">tag!</a> <a href="./index.html#datatypexex">datatype!</a>, <br>otherwise <a href="./index.html#false">false</a>.<br><br>Arguments<br><br>Its single argument can be <a href="./index.html#anytypexex">anytype!</a>.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; explore tag?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>>> t: <x y=""><br>== <x y=""><br>>> tag? t<br>== true<br>>> tag? "<a b="">"<br>== false<br><br><br></a><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></x></x></pre><br><br><span class="mike-large" id="tail"> tail</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#tail">tail</a> can be used to set a <a href="./index.html#seriesxex">series!</a> index right<br>after the last item in the <a href="./index.html#seriesxex">series!</a>.<br><br>关键字 <a href="./index.html#tailxqm">tail?</a> can be used to test if a <a href="./index.html#seriesxex">series!</a> is at <a href="./index.html#tail">tail</a>.<br><br>关键字 <a href="./index.html#indexxqm">index?</a> can be used to obtain the current index.<br></pre>例子<pre>red>> x: [1 2 3 4 5]<br>== [1 2 3 4 5]<br><br>red>> head? x<br>== true<br><br>red>> index? x<br>== 1<br><br>red>> x: tail x<br>== []<br><br>red>> tail? x<br>== true<br><br>red>> index? x<br>== 6 <b style="color: green">; Note that the index is one beyond the last element!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tailxqm"> tail?</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#tailxqm">tail?</a> tests if a <a href="./index.html#seriesxex">series!</a> is at <a href="./index.html#tail">tail</a> position; <br>it returns <a href="./index.html#true">true</a> if at <a href="./index.html#tail">tail</a> or <a href="./index.html#false">false</a> otherwise.<br><br>关键字 <a href="./index.html#indexxqm">index?</a> can be used to obtain the current index.<br></pre>例子<pre>red>> x: [1 2 3 4 5]<br>== [1 2 3 4 5]<br><br>red>> head? x<br>== true<br><br>red>> index? x<br>== 1<br><br>red>> x: tail x<br>== []<br><br>red>> tail? x<br>== true<br><br>red>> index? x<br>== 6 <b style="color: green">; Note that the index is one beyond the last element!</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="take"> take</span> type: action! Categories: <a href="./index.html#cat-s01">序列</a><br><pre>关键字 <a href="./index.html#take">take</a> removes and returns one or more elements of a <a href="./index.html#seriesxex">series!</a>. <br><br>Using <a href="./index.html#append">append</a> with <a href="./index.html#take">take</a> and its /tail refinement lets us use a <a href="./index.html#seriesxex">series!</a> <br>as a stack or queue.<br><br>Arguments<br> The single argument is a <a href="./index.html#seriesxex">series!</a> or <a href="./index.html#nonexex">none!</a><br><br>Refinements<br> /part - specifies a length or end position. <br> Supply a length (a <a href="./index.html#numberxex">number!</a>) or a position in a <a href="./index.html#seriesxex">series!</a><br> /deep - copy nested series values.<br> /last - take from from the tail end.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Examples of take, and some refinements</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> s: [11 22 33 44 55]<br><br>red>> take s<br>== 11<br><br>red>> s<br>== [22 33 44 55]<br><br>red>> s: [11 22 33 44 55]<br>== [11 22 33 44 55]<br><br>red>> take/last s<br>== 55<br><br>red>> s<br>== [11 22 33 44]<br><br>red>> s: [11 22 33 44 55]<br>== [11 22 33 44 55]<br><br>red>> take/part s 3<br>== [11 22 33]<br><br>red>> s<br>== [44 55]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tan"> tan</span> type: routine! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="tangent"> tangent</span> type: native! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>关键字 <a href="./index.html#tangent">tangent</a> returns the trigonometric tangent of a <a href="./index.html#numberxex">number!</a><br>of degrees.<br><br>It has one numeric parameter.<br><br>Refinements:<br> /radians : expects the input value in radians;<br> without refinement expects the input value in degrees.<br></pre>例子<pre>tangent 45<br>== 1.0<br><br>tangent 60 * 1.1<br>== 2.246036773904216<br><br>tangent/radians 1.05<br>== 1.74331530998317<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="third"> third</span> type: function! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#third">third</a> returns the third value in a <a href="./index.html#seriesxex">series!</a> (also <a href="./index.html#stringxex">string!</a>s).<br><br>The argument can be one of: <br> <a href="./index.html#seriesxex">series!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#pairxex">pair!</a><br><br>If there is no third item, <a href="./index.html#none">none</a> is returned.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Third of block </b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> third [2 3 4 5]<br>== 4<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Third of a string is a character type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> third "ABCDE"<br>== #"C"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Third of a tuple</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> third 22.33.44.55<br>== 44<br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; No third here</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> third[44]<br>== none<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="throw"> throw</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a>, <a href="./index.html#cat-e01">错误</a><br><pre>Throws control to a <a href="./index.html#catch">catch</a>. Note that <a href="./index.html#catch">catch</a> and throw are mainly <br>intended for creating new control structures, and are not the main <br>exception-handling functions. For this, look at <a href="./index.html#attempt">attempt</a>, <a href="./index.html#try">try</a>, <br><a href="./index.html#cause-error">cause-error</a> <a href="./index.html#errorxqm">error?</a>, and <a href="./index.html#errorxex">error!</a>.<br><br>For <a href="./index.html#throw">throw</a> examples, look at the entry for <a href="./index.html#catch">catch</a>.<br> <br>Arguments<br><br>The single argument value, can be any type, and will be the value returned <br>from the matching <a href="./index.html#catch">catch</a>.<br><br>Refinements<br> /name - Throws to a named catch. We supply a <a href="./index.html#word">word</a>.<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="timexex"> time!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The Time! <a href="./index.html#datatypexex">datatype!</a> lets us express an amount of time in hours, minutes, <br>seconds, and subseconds. Both positive and negative times are permitted. <br>Colons separate items, apart from subseconds, which use a decimal point.<br><br>Times are stored in a standard form, irrespective of how they are entered. <br>(Thus, 59 minutes and 63 seconds are stored as 1 hour, 0 minutes, and 3 seconds.)<br><br>The refinements /hour /minute /second can be used to get part of a time.<br><br>Times can be compared, and used in calculations where a time result is meaningful. <br>For example, we can add two times, but not multiply them.<br><br>The <a href="./index.html#to-time">to-time</a> function can be used to convert other values into a <a href="./index.html#timexex">time!</a>.<br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create some times, work with them.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>; Create times <br>>> t1: 3:4:58<br>== 3:04:58<br>>> t2: 24:0:63<br>== 24:01:03<br>>> t3: 3:0.95<br>== 0:03:00.950000001<br><br>; Refinement <br>>> t1/second<br>== 58.0<br><br>; Comparison<br>>> t1 > t2<br>== false<br><br>; Calculations<br>>> t1 * 2.9<br>== 8:56:24.2<br>>> t1 + t2<br>== 27:06:01<br><br>>> t1 * t2<br>*** Script Error: incompatible argument for multiply of time!<br>*** 位置:*<br><br>; Use of to-time function<br>>> to-time [11 22 33]<br>== 11:22:33<br>>> to-time [11 22 61]<br>== 11:23:01<br>>> to-time "12:24"<br>== 12:24:00<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="timexqm"> time?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#timexqm">time?</a> returns <a href="./index.html#true">true</a> if the value is a <a href="./index.html#timexex">time!</a>, <br>otherwise <a href="./index.html#false">false</a>.<br><br>Arguments<br> Has one argument, which can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Show usage here</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> time? 3:15<br>== true<br><br>red>> type? 3:15<br>== time!<br><br>red>> time? 3.15<br>== false<br><br>red>> type? 3.15<br>== float!<br><br>red>> t: 3:45<br>== 3:45:00.0<br><br>red>> time? t<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to"> to</span> type: action! Categories: <a href="./index.html#cat-c01">生成类型</a>, <a href="./index.html#cat-c07">转换</a><br><pre>关键字 <a href="./index.html#to">to</a> converts a value to a specified <a href="./index.html#datatypexex">datatype!</a>. <br>Only specific conversions are allowed.<br><br>Arguments:<br> type - a <a href="./index.html#datatypexex">datatype!</a> name. Note that this name can be the result of an evaluation.<br> spec - the attributes of the new value. Often, this is simply the value itself.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Do some simple conversions</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to integer! 2.333<br>2<br><br>red>> to string! 234<br>"234"<br><br>red>> to integer! "23456"<br>23456<br><br>red>> to integer! "33" <br>== 33<br><br>red>> to set-word! "foo"<br>== foo:<br><br>red>> to word! "bar"<br>== bar<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Compute the new type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> affect: true<br>true<br><br>red>> to either affect [float!] [string!] 567<br>567.0<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to-email"> to-email</span> type: unset! Categories: <a href="./index.html#cat-c07">转换</a><br><pre>Converts a value to an <a href="./index.html#emailxex">email!</a> type.<br><br>Arguments<br><br>It takes a single value.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Do some conversions to email!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>; String<br>>> to-email "[email protected]"<br>== [email protected]<br><br>; Block<br>>> to-email [a @b.c]<br>== [email protected]<br>; and confirm the type<br>>> type? to-email [a @b.c]<br>== email!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to-hex"> to-hex</span> type: native! Categories: <a href="./index.html#cat-b01">数字基础</a><br><pre>关键字 <a href="./index.html#to-hex">to-hex</a> converts an <a href="./index.html#integerxex">integer!</a> to a hexadecimal <br>value, with a leading # and leading zeroes.<br><br>Its argument is an <a href="./index.html#integerxex">integer!</a>.<br> <br>Refinements<br> /size - an <a href="./index.html#integerxex">integer!</a> specifying the number of <br> hexadecimal digits in the result. <br> No errors result if a small size value <br> removes significant parts of the result.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Conversions of positive and negative <a href="./index.html#integerxex">integer!</a>s</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex 64<br>#00000040<br><br>red>> to-hex -1<br>#FFFFFFFF<br><br>red>> to-hex 2 ** 31<br>== #80000000 <b style="color: green">; Left most bit (= sign bit) is set</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Limit digits with /size (from the right)</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-hex/size 64 4<br>#0040<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to-image"> to-image</span> type: function! Categories: <a href="./index.html#cat-u01">未知</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="to-local-file"> to-local-file</span> type: native! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#to-local-file">to-local-file</a> converts standard, system independent Red <br>file paths to the file format used by the local operating system. <br><br>The path argument must be a <a href="./index.html#filexex">file!</a> or a <a href="./index.html#stringxex">string!</a>.<br><br>Refinements<br> /full - prepends current dir for full path (for relative paths only)<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Windows - using Red <a href="./index.html#filexex">file!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-local-file %/c/data.txt<br>"c:\data.txt"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Windows - using a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-local-file "/c/data.txt"<br>"c:\data.txt"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Windows - with /full refinement</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> what-dir<br>== %/E/Websites/Red-by-Example/auto-v5/ <b style="color: green">; Current directory</b><br><br>red>> to-local-file/full %data.txt <b style="color: green">; Relative path</b><br>== "E:\Websites\Red-by-Example\auto-v5\data.txt"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to-red-file"> to-red-file</span> type: function! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#to-red-file">to-red-file</a> converts a local file system path to Red's <br>standard machine independent path format. <br><br>The argument can be:<br> - a Red <a href="./index.html#filexex">file!</a><br> - a <a href="./index.html#stringxex">string!</a>.<br><br>Note that a Red file path - preceded by % - cannot contain a colon (:) <br> as used in Windows paths, though it can contain \. <br> The string argument can contain a colon (:).<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Convert a file containing backslashes</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-red-file %\data\notes.txt<br>%/data/notes.txt<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Convert a Windows file in a string</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> to-red-file "C:\data\notes.txt"<br>%/C/data/notes.txt<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="to-tag"> to-tag</span> type: unset! Categories: <a href="./index.html#cat-c07">转换</a><br><pre>Converts its single argument to a <a href="./index.html#tagxex">tag!</a>.<br><br>Arguments<br><br>A single argument, of any type.<br><br></pre>例子<pre><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Explore to-tag, with several types of arguments.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; integer!<br>>> to-tag 1234<br>== <1234><br>>> v: 3 + 5<br>== 8<br>>> to-tag v<br>== <8><br><br>; string!<br>>> to-tag "the cat"<br>== <the cat=""><br>>> block!<br>to-tag [a b]<br>== <ab><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></ab></the></pre><br><br><span class="mike-large" id="to-time"> to-time</span> type: unset! Categories: <a href="./index.html#cat-c07">转换</a><br><pre>Converts a value to a <a href="./index.html#timexex">time!</a>.<br><br>Arguments<br><br>A single value.<br><br></pre>例子<pre>>> to-time [11 22 33]<br>== 11:22:33<br>>> to-time [11 22 61]<br>== 11:23:01<br>>> to-time "12:24"<br>== 12:24:00<br>>> t1 + t2<br>== 27:06:01<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="trim"> trim</span> type: action! Categories: <a href="./index.html#cat-s04">字符串操作</a><br><pre>word <a href="./index.html#trim">trim</a> removes white space (tabs and spaces) from a <a href="./index.html#stringxex">string!</a> or <a href="./index.html#none">none</a> <br>from a <a href="./index.html#blockxex">block!</a> or <a href="./index.html#objectxex">object!</a>. The value of the argument is altered.<br> <br>The argument can be one of: <a href="./index.html#seriesxex">series!</a> <a href="./index.html#objectxex">object!</a> <a href="./index.html#errorxex">error!</a> <a href="./index.html#mapxex">map!</a><br><br>Refinements<br> /head - Removes only from the head.<br> /tail - Removes only from the tail.<br> /auto - Auto indents lines relative to first line.<br> /lines - Removes all line breaks and extra spaces.<br> /all - Removes all whitespace (but not line breaks).<br> /with - Same as /all, but removes characters in a 'with' argument we supply. <br> It must be one of: <a href="./index.html#charxex">char!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#integerxex">integer!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Basic trim.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: " some text "<br>== " some text "<br><br>red>> trim str <b style="color: green">; Both head and tail are trimmed</b><br>== "some text"<br><br>red>> str<br>== "some text" <b style="color: green">; str was altered by trim</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Multiple lines of text - enclosed in { }</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: {Four lines<br>{ of varying levels<br>{ of<br>{ indentation.}<br>== {Four lines^/ of varying levels^/ of^/ indentation.}<br><br>red>> trim str <b style="color: green">; ^/ means a newline</b><br>== {Four lines^/of varying levels^/of^/indentation.}<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Trim a <a href="./index.html#blockxex">block!</a> - NB <a href="./index.html#reduce">reduce</a> evaluates every element in a block</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> blk: [none none 3 none]<br>== [none none 3 none]<br><br>red>> trim blk<br>== [none none 3 none] <b style="color: green">; Because elements are not yet evaluated</b><br><br>red>> blk<br>== [none none 3 none] <b style="color: green">; Trim did not alter the block</b><br><br>red>> trim reduce blk <br>== [3] <b style="color: green">; Now trim worked succesfully!</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /head - trim head only</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> trim/head " AAA "<br>== "AAA "<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /tail - trim tail only</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> trim/tail " AAA "<br>== " AAA"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /lines - NB last line has line break at end</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: { Two lines <br>{ of text<br>{ }<br>== " Two lines ^/ of text^/ "<br><br>red>> trim/lines str<br>== "Two lines of text" <b style="color: green">; Multiple spaces and line breaks are gone</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /all - remove all space</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> trim/all " some text "<br>== "sometext"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /with - Note that spaces are not removed automatically</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> str: "some extra-characters,, to use"<br>== "some extra-characters,, to use"<br><br>red>> trim/with str ",-"<br>== "some extracharacters to use" <b style="color: green">; , and - removed</b><br><br>red>> str: "some extra-characters,, to use"<br>== "some extra-characters,, to use"<br><br>red>> trim/with str ",- "<br>== "someextracharacterstouse" <b style="color: green">; Now also spaces removed</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="true"> true</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>关键字 <a href="./index.html#true">true</a> has the logical value "true" <br>and its <a href="./index.html#datatypexex">datatype!</a> is <a href="./index.html#logicxex">logic!</a><br><br>Logical values are produced from various comparisons.<br><br>The <a href="./index.html#logicxex">logic!</a> type also provides: <br> <a href="./index.html#false">false</a>, <a href="./index.html#no">no</a>, <a href="./index.html#off">off</a>, <a href="./index.html#on">on</a>, <a href="./index.html#true">true</a>, <a href="./index.html#yes">yes</a><br></pre>例子<pre>3 = 3.0<br>== true<br><br>3 == 3.0<br>== false<br><br>3 = 4<br>== false<br><br>"abc" = "abc"<br>== true<br><br>"ABC" = "abc"<br>== true<br><br>if 4 > 3 [print "it is"]<br>-- it is<br><br>a: true<br>== true<br><br>b: 4 > 3<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="try"> try</span> type: native! Categories: <a href="./index.html#cat-e01">错误</a><br><pre>Tries to evaluate a block, similar to <a href="./index.html#do">do</a>. The value of the block is<br>returned, but if an <a href="./index.html#errorxex">error!</a> occurs, the block is abandoned, and an <br>error value is returned. <br><br>Normally, the error is displayed, but we can intercept it with a <br>function to prevent the display. Often, the <a href="./index.html#errorxqm">error?</a> function is <br>used for this. We can also access the returned <a href="./index.html#errorxex">error!</a> object <br>to get details of the error.<br><br>Note that <a href="./index.html#try">try</a> is concerned with error-handling, and should not <br>be used with <a href="./index.html#catch">catch</a> and <a href="./index.html#throw">throw</a>, which are intended for building <br>control structures.<br><br>For other error/exception-handling words, look at the related entries <br>for <a href="./index.html#attempt">attempt</a>, <a href="./index.html#cause-error">cause-error</a>, <a href="./index.html#errorxqm">error?</a>, and the <a href="./index.html#errorxex">error!</a> type.<br><br><br>Arguments<br>Its single argument is a <a href="./index.html#blockxex">block!</a><br><br>Refinements<br> /all - detects also <a href="./index.html#break">break</a>, <a href="./index.html#continue">continue</a>, <a href="./index.html#return">return</a>, <a href="./index.html#exit">exit</a> <br> and <a href="./index.html#throw">throw</a> exceptions.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; try, cause-error, and error? usage examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>;A toy function for the examples. It basically does a divide, but<br>;we cause a 'positive' error if the first argument is not positive<br>;and we also anticipate that a zero-divide error might occur. <br>do-average: function [<br> "calc average from positive total, non-zero count"<br> total [integer!] count [integer!]] [<br> print ["In do-average with " total count]<br> if not positive? total [<br> cause-error 'math 'positive []<br> ]<br> total / count ;might cause an error<br>]<br><br>print "No errors here:"<br>print do-average 10 2<br>print ""<br><br>;the following line (commented out now) displayed:<br>; *** Math Error: positive number required<br>; *** Where: do<br>; and then halted.<br><br>; print do-average -10 2 ;I am commented-out now<br><br><br>print "Use try and error? - should trigger 'cause-error'"<br>either error? result: try [do-average -10 2] [<br> print ["Error id: " result/id]<br>] [<br> print ["No errors, result is: " result]<br>]<br><br>print "Use try and error? - force a zero-divide"<br>either error? result: try [do-average 10 0] [<br> print ["Error id: " result/id]<br>] [<br> print ["No errors, result is: " result]<br>]<br><br>print "Use try and error? - no errors expected "<br>either error? result: try [do-average 10 2] [<br> print ["Error id: " result/id]<br>] [<br> print ["No errors, result is: " result]<br>]<br>print "Done."<br><br>THE OUTPUT IS:<br>--------------<br><br>No errors here:<br>In do-average with 10 2<br>5<br><br>Use try and error? - should trigger 'cause-error'<br>In do-average with -10 2<br>Error id: positive<br>Use try and error? - force a zero-divide<br>In do-average with 10 0<br>Error id: zero-divide<br>Use try and error? - no errors expected <br>In do-average with 10 2<br>No errors, result is: 5<br>Done.<br><br><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; /all refinement examples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; make a 'break' error. Try does not detect it.<br>red>> error? try [print 3 + 4 break "done"]<br>7<br>*** Throw Error: no loop to break<br>*** Where: break<br><br>; now use /all to detect it (as well as any other errors)<br>red>> error? try/all [print 3 + 4 break "done"]<br>7<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tuplexex"> tuple!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#tuplexex">tuple!</a> is a list of 3 up to 12 bytes. <br>It offers a versatile way to represent different kind of values such as <br>version numbers, IP addresses , and colours (example: 0.255.0).<br><br>The value of each item in a tuple must be in the range 0 to 255.<br><br>Once a <a href="./index.html#tuplexex">tuple!</a> value is created, its size cannot be changed anymore (it is not a series!), <br>but its elements can still be modified, using, for example, path syntax. <br> <br>The following actions are supported by tuple! values: <br> <a href="./index.html#random">random</a>, <a href="./index.html#add">add</a>, <a href="./index.html#divide">divide</a>, <a href="./index.html#multiply">multiply</a>, <a href="./index.html#remainder">remainder</a>, <a href="./index.html#subtract">subtract</a>, <br> <a href="./index.html#and">and</a>, <a href="./index.html#or">or</a>, <a href="./index.html#xor">xor</a>, <a href="./index.html#lengthxqm">length?</a>, <a href="./index.html#pick">pick</a>, <a href="./index.html#poke">poke</a>, <a href="./index.html#reverse">reverse</a>.<br> <br>Math operations are allowed with some other scalar datatypes where a result is sensible, <br>like <a href="./index.html#integerxex">integer!</a>, <a href="./index.html#floatxex">float!</a> and <a href="./index.html#percentxex">percent!</a>.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create 2 tuples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t1: 6.3.2<br>== 6.3.2<br><br>red>> t2: 100.200.64.32<br>== 100.200.64.32<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Path syntax to access and modify an element</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t2/2<br>== 200<br><br>red>> t2/2: 250<br>== 250<br><br>red>> t2<br>== 100.250.64.32<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add the tuples</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t1 + t2<br>== 106.253.66.32<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add an integer - note clipping at 255</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t2 + 200<br>== 255.255.255.232<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Get help on defined colours</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> help tuple!<br><b style="color: blue"> aqua : 40.100.130</b><br><b style="color: blue"> beige : 255.228.196</b><br><b style="color: blue"> black : 0.0.0</b><br><b style="color: blue"> blue : 0.0.255</b><br><b style="color: blue"> brick : 178.34.34</b><br><b style="color: blue"> ... and 100 or so lines more, not shown here</b><br> <br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Compare pre-defined colours</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> red + green = yellow<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="tuplexqm"> tuple?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#tuplexqm">tuple?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#tuplexex">tuple!</a>, <br>otherwise <a href="./index.html#false">false</a>.<br><br>Its argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test a valid <a href="./index.html#tuplexex">tuple!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t: 22.44.33<br>22.44.33<br><br>red>> tuple? t<br>true<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test an integer</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> n: 123<br>123<br><br>red>> tuple? n<br>false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="typexqm"> type?</span> type: native! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#typexqm">type?</a> returns the <a href="./index.html#datatypexex">datatype!</a> of a value.<br><br>The argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Get the type of several items</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> type? 123<br>== integer!<br><br>red>> type? [1 2 3]<br>== block!<br><br>red>> x: 22x33<br>== 22x33<br><br>red>> type? x<br>== pair!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="typesetxex"> typeset!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#typesetxex">typeset!</a> lets us create a set of types and name them. <br><br>Internally, a typeset is stored in a compact array of bits, for fast access <br>at run-time. By convention, <a href="./index.html#typesetxex">typeset!</a> names should end with a ! <br> <br>The following words are supported with <a href="./index.html#typesetxex">typeset!</a>s: <br> <a href="./index.html#make">make</a><br> <a href="./index.html#form">form</a><br> <a href="./index.html#mold">mold</a><br> <a href="./index.html#and">and</a><br> <a href="./index.html#or">or</a><br> <a href="./index.html#xor">xor</a><br> <a href="./index.html#complement">complement</a><br> <a href="./index.html#clear">clear</a><br> <a href="./index.html#find">find</a><br> <a href="./index.html#insert">insert</a><br> <a href="./index.html#append">append</a><br> <a href="./index.html#lengthxqm">length?</a>.<br> <br>Comparison operators are also supported.<br><br>Typesets cannot be built from existing typesets; use the low-level types instead.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Red uses <a href="./index.html#typesetxex">typeset!</a>s internally:</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> ? typeset!<br> any-block! : make typeset! [block! paren! path! lit-path! set-path! <br> get-path! hash!]<br> any-function! : make typeset! [native! action! op! function! routine!]<br> any-list! : make typeset! [block! paren! hash!]<br> any-object! : make typeset! [object! error!]<br> any-path! : make typeset! [path! lit-path! set-path! get-path!]<br> any-string! : make typeset! [string! file! url!]<br> any-type! : make typeset! [datatype! unset! none! logic! block! <br> paren! string! file! url! char! integer! <br> float! word! set-word! lit-word! get-word! <br> refinement! issue! native! action! op! <br> function! path! lit-path! set-path! <br> get-path! routine! bitset! object! typeset! <br> error! vector! hash! pair! percent! tuple! <br> map! binary! time! image! event!]<br> any-word! : make typeset! [word! set-word! lit-word! get-word! <br> refinement! issue!]<br> default! : make typeset! [datatype! none! logic! block! paren! <br> string! file! url! char! integer! float! <br> word! set-word! lit-word! get-word! <br> refinement! issue! native! action! op! <br> function! path! lit-path! set-path! <br> get-path! routine! bitset! object! <br> typeset! error! vector! hash! pair! <br> percent! tuple! map! binary! time! image!]<br> immediate! : make typeset! [datatype! none! logic! char! integer! <br> float! word! set-word! lit-word! <br> get-word! refinement! issue! typeset! <br> pair! percent! tuple! time!]<br> internal! : make typeset! [unset! event!]<br> my-type! : make typeset! [integer! pair! tuple!]<br> number! : make typeset! [integer! float! percent!]<br> scalar! : make typeset! [char! integer! float! pair! percent! tuple! time!]<br> series! : make typeset! [block! paren! string! file! url! path! lit-path! <br> set-path! get-path! vector! hash! binary! image!]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Make a new type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> my-type!: make typeset! [pair! tuple! integer!]<br>== make typeset! [integer! pair! tuple!]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a function which uses the type</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> show-it: function [x [my-type!] ] [ print x ]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try it with pair, tuple, integer</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> show-it 30x40 <b style="color: green">; <a href="./index.html#pairxex">pair!</a> is part of this <a href="./index.html#typesetxex">typeset!</a></b><br>30x40<br><br>red>> show-it 33.44.2 <b style="color: green">; <a href="./index.html#tuplexex">tuple!</a> is part of this <a href="./index.html#typesetxex">typeset!</a></b><br>33.44.2<br><br>red>> show-it 234 <b style="color: green">; <a href="./index.html#integerxex">integer!</a> is part of this <a href="./index.html#typesetxex">typeset!</a></b><br>234<br><br>red>> show-it 23.45 <b style="color: green">; <a href="./index.html#floatxex">float!</a> is NOT part of this <a href="./index.html#typesetxex">typeset!</a></b><br>*** Script error: show-it does not allow float! for its x argument<br>*** Where: show-it<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try to make a typeset from the existing <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#numberxex">number!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> t!: make typeset![number!]<br>*** Script error: invalid argument: number!<br>*** Where: make<br>red>> <br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="typesetxqm"> typeset?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#typesetxqm">typeset?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#typesetxex">typeset!</a>, <br>otherwise <a href="./index.html#false">false</a>.<br><br>The argument can be of any type<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; <a href="./index.html#integerxex">integer!</a> is a type, not a typeset!</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> typeset? integer!<br>== false<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; <a href="./index.html#numberxex">number!</a> is a <a href="./index.html#typesetxex">typeset!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> typeset? number!<br>== true<br><br>red>> ? number!<br>number! is a typeset! of value: make typeset! [integer! float! percent!]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Test a self made <a href="./index.html#typesetxex">typeset!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> my-type!: make typeset! [pair! tuple! integer!]<br>== make typeset! [integer! pair! tuple!]<br><br>red>> typeset? my-type!<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="union"> union</span> type: native! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s02">集合</a><br><pre>关键字 <a href="./index.html#union">union</a> returns the union of 2 data sets. <br>Duplicate entries are only included once.<br><br>A new <a href="./index.html#seriesxex">series!</a> is produced, and the 2 arguments are unchanged.<br><br>Both series arguments must be of the same datatype, which can be:<br> <a href="./index.html#blockxex">block!</a> <a href="./index.html#hashxex">hash!</a> <a href="./index.html#stringxex">string!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a><br><br>关键字 <a href="./index.html#union">union</a> is one of several set-type functions.<br><br>Refinements:<br> /case - use case-sensitive comparison<br> /skip - treat the series as fixed size records. <br> Specify the size as an <a href="./index.html#integerxex">integer!</a><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Union of 2 blocks</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> union [1 2 99 4] [1 2 3 4]<br>== [1 2 99 4 3]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Union of 2 strings</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> union "abcd" "Ab"<br>== "abcd"<br><br>; /case makes union case-sensitive<br>red>> union/case "abcd" "Ab"<br>== "abcdA"<br><br>red>> union/case ["a" "b"] [ "A"]<br>== ["a" "b" "A"]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unique"> unique</span> type: native! Categories: <a href="./index.html#cat-s01">序列</a>, <a href="./index.html#cat-s02">集合</a><br><pre>关键字 <a href="./index.html#unique">unique</a> takes a <a href="./index.html#seriesxex">series!</a> as its argument and removes <br>all duplicates.<br><br>Refinements:<br> /skip - groups of items are made unique<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Leave only the unique values</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> unique [1 2 3 4 2 5 4 1 3 2]<br>== [1 2 3 4 5]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Make groups of 2 items unique</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> unique/skip [1 2 3 4 1 2 3 4 5 6 7 8 5 6] 2<br>== [1 2 3 4 5 6 7 8]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Unique characters in a <a href="./index.html#stringxex">string!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> unique "abcbcdcdedefefg"<br>== "abcdefg"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Unique groups of 3 characters</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> unique/skip "abcdefabcghijklmnoghi" 3<br>== "abcdefghijklmno"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unless"> unless</span> type: native! Categories: <a href="./index.html#cat-c03">条件分支</a><br><pre>关键字 <a href="./index.html#unless">unless</a> evaluates the <a href="./index.html#blockxex">block!</a> if the condition is NOT <a href="./index.html#true">true</a>,<br>returning the value of the block; otherwise returns <a href="./index.html#none">none</a>.<br><br>The arguments are a condition, and a <a href="./index.html#blockxex">block!</a>.<br><br>Using <a href="./index.html#unless">unless</a> is equivalent to using <a href="./index.html#if">if</a> <a href="./index.html#not">not</a>.<br></pre>例子<pre>age: 18<br>unless (age < 18) or (age > 100) [print "Within Range"]<br><b style="color: blue">Within range</b><br><br>if not( (age < 18) or (age > 100)) [print "Within Range"]<br><b style="color: blue">Within range</b><br><b style="color: green">; equivalent if (for previous unless example)</b><br><br>if (age >= 18) and (age <= 100) [print "Within Range"]<br><b style="color: blue">Within range</b><br><b style="color: green">; same with condition rewritten</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unset"> unset</span> type: native! Categories: <a href="./index.html#cat-w01">标识符操作</a><br><pre>Unsets the value of a word in its current context. <br><br>Its single argument can be a <a href="./index.html#wordxex">word!</a> or <a href="./index.html#blockxex">block!</a> of words.<br><br>(Awaiting additional documentation by red-by-example team.)<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unsetxex"> unset!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a>, <a href="./index.html#cat-w01">标识符操作</a><br><pre>This type comes into existence when value slots in memory just contain random <br>garbage. It is possible to use it when specifying function argument types, <br>but doing so reduces Red's error detection.<br><br>There are no examples currently.<br><br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unsetxqm"> unset?</span> type: function! Categories: <a href="./index.html#cat-w01">标识符操作</a><br><pre>Returns <a href="./index.html#true">true</a> if its argument is of the <a href="./index.html#unsetxex">unset!</a> type, otherwise <a href="./index.html#false">false</a>. <br>The <a href="./index.html#valuexqm">value?</a> word is also useful in this area.<br><br>Its single argument can be of any type.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; unset? and value?</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>; print does not return a value<br>red>> unset? print 22<br>22<br>== true<br><br>; value? does not work with unset!<br>red>> value? print 22<br>22<br>*** Script Error: value? does not allow unset! for its value argument<br>*** Where: value?<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="until"> until</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#until">until</a> evaluates its <a href="./index.html#blockxex">block!</a> argument until the <a href="./index.html#blockxex">block!</a><br>returns a <a href="./index.html#true">true</a> value.<br><br>It has one argument, a <a href="./index.html#blockxex">block!</a>.<br></pre>例子<pre>n: 5<br>until [<br> print n<br> n: n - 1<br> n < 0<br>]<br><b style="color: blue">5</b><br><b style="color: blue">4</b><br><b style="color: blue">3</b><br><b style="color: blue">2</b><br><b style="color: blue">1</b><br><b style="color: blue">0</b><br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="unview"> unview</span> type: unset! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="uppercase"> uppercase</span> type: native! Categories: <a href="./index.html#cat-s04">字符串操作</a><br><pre>关键字 <a href="./index.html#uppercase">uppercase</a> converts a string of characters to upper-case. <br> <br>The single argument can be a <a href="./index.html#stringxex">string!</a> or a <a href="./index.html#charxex">char!</a>.<br><br>Refinements:<br> /part - limits to a given length or position.<br><br>NOTE: this is a destructive operation. <br> When applying it to a variable, that variable will be changed!<br><br>See also <a href="./index.html#lowercase">lowercase</a>.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try uppercase on char and string</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> uppercase #"a"<br>#"A"<br><br>red>> uppercase "ABC def"<br>"ABC DEF"<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use /part to specify first 2 chars only</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> uppercase/part "abcd def" 2<br>ABcd def"<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="urlxex"> url!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a>, <a href="./index.html#cat-u02">URL</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#urlxex">url!</a> (Uniform Resource Locator) lets us <br>access web pages, images, files, ftp, email, and other protocols. <br><br>It is a <a href="./index.html#seriesxex">series!</a> similar to a string, and values take the pattern:<br> protocol://path<br>For example:<br> http://www.red-lang.org/p/about.html<br><br>A <a href="./index.html#urlxex">url!</a> can be used with a variety of words, such as <a href="./index.html#do">do</a>, <a href="./index.html#load">load</a>, <br><a href="./index.html#read">read</a>, <a href="./index.html#write">write</a> and <a href="./index.html#save">save</a>. <br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a URL, read the file</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> web-file: http://www.red-lang.org/p/about.html<br>== http://www.red-lang.org/p/about.html<br><br>red>> type? web-file<br>== url!<br><br>red>> read web-file<br><b style="color: green">; Output suppressed</b><br><br>red>> print read web-file<br><b style="color: green">; Output suppressed</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="urlxqm"> url?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a>, <a href="./index.html#cat-u02">URL</a><br><pre>Returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#urlxex">url!</a> type, otherwise <a href="./index.html#false">false</a>.<br>It does not do a complete check of the URL for current protocols.<br><br>Arguments<br>Its single argument can be of any type. <br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try url? on various types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;string type, not a url<br>red>> url? "http://www.google.com/"<br>== false<br><br>;a url<br>red>> url? http://www.google.com/<br>== true<br><br>;a non-existent protocol, still a url<br>red>> url? xxx://a.b.c<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="valuexqm"> value?</span> type: native! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#valuexqm">value?</a> returns <a href="./index.html#true">true</a> if the argument is a Red <a href="./index.html#wordxex">word!</a><br>that has been set; otherwise returns <a href="./index.html#false">false</a>.<br><br>It has 1 argument, a <a href="./index.html#wordxex">word!</a>, which is passed as a literal<br>or as the result of other operations.<br></pre>例子<pre>a: 33<br>== 33<br><br>value? 'a<br>== true<br><br>a: none<br>== none<br><br>value? 'a<br>== true<br><br>value? 'fish<br>== false<br><br>value? second [a fish]<br>== false<br><br>value? fish<br>*** Script error: fish has no value<br>*** Where: value?<br><b style="color: green">; NOTE the error message;</b><br><b style="color: green">; we must prevent evaluation of the word by using ' or [ ].</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="values-of"> values-of</span> type: function! Categories: <a href="./index.html#cat-r01">反射</a><br><pre>Returns the list of values of a value that supports reflection. <br><br>Arguments<br><br>A value of a type that supports reflection.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; values-of, with map and object</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;with a map<br>red>> m: make map![a 1 b 2]<br>== #(<br> a: 1<br> b: 2<br>)<br>red>> values-of m<br>== [1 2]<br><br>;with an object<br>red>> place: make object! [ x-pos: 100 y-pos: 200 ]<br>red>> values-of place<br>== [100 200]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="vectorxex"> vector!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>The <a href="./index.html#datatypexex">datatype!</a> <a href="./index.html#vectorxex">vector!</a> represents a <a href="./index.html#seriesxex">series!</a> type.<br><br>A <a href="./index.html#vectorxex">vector!</a> is a high-performance <a href="./index.html#seriesxex">series!</a> of items. <br>The items in a <a href="./index.html#vectorxex">vector!</a> must all have the same type (unlike a <a href="./index.html#blockxex">block!</a>).<br><br>The allowable item types are:<br> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#floatxex">float!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#percentxex">percent!</a><br>Vectors of <a href="./index.html#stringxex">string!</a> are not allowed.<br><br>To create a vector, we use <a href="./index.html#make">make</a>, as in:<br> v-ages: make vector! [80 18 65]<br><br>At least one value must be given, to allow to determine the type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; First create a <a href="./index.html#vectorxex">vector!</a> of <a href="./index.html#integerxex">integer!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> v-ages: make vector! [80 18 65]<br>== make vector! [80 18 65]<br><br>red>> print v-ages<br><b style="color: blue">80 18 65</b><br><br>red>> print mold v-ages<br><b style="color: blue">make vector! [80 18 65]</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Add a new item to that <a href="./index.html#vectorxex">vector!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> append v-ages 99<br>== make vector! [80 18 65 99]<br><br>red>> print v-ages<br><b style="color: blue">80 18 65 99</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Obtain the length of it</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print length? v-ages<br><b style="color: blue">4</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Extract an item using path notation</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> print v-ages/2 <br><b style="color: blue">18</b><br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Return sub <a href="./index.html#seriesxex">series!</a> starting with found item</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> find v-ages 18<br>== make vector! [18 65 99]<br><br><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Loop through a <a href="./index.html#vectorxex">vector!</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> grades: make vector![ #"A" #"B" #"F"]<br>== make vector! [#"A" #"B" #"F"]<br><br>red>> foreach grade grades [print grade]<br><b style="color: blue">A</b><br><b style="color: blue">B</b><br><b style="color: blue">F</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="vectorxqm"> vector?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#vectorxqm">vector?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#vectorxex">vector!</a>, otherwise <a href="./index.html#false">false</a>.<br><br>Its single argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Create a <a href="./index.html#vectorxex">vector!</a> and a <a href="./index.html#blockxex">block!</a>, then explore <a href="./index.html#vectorxqm">vector?</a></b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> v-ages: make vector! [80 18 65]<br>== make vector! [80 18 65]<br><br>red>> vector? v-ages<br>== true<br><br>red>> a-block: [ 80 18 85]<br>== [80 18 85]<br><br>red>> vector? a-block<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="view"> view</span> type: unset! Categories: <a href="./index.html#cat-g01">GUI (VID)</a><br><pre>The function <a href="./index.html#view">view</a> is used to:<br> - declare a GUI layout using VID<br> - invoke that GUI layout<br></pre>例子<pre>Red [<br> needs: 'view<br>]<br><br>view [<br> below<br> text "Line 1"<br> text "Line 2"<br>]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="wait"> wait</span> type: native! Categories: <a href="./index.html#cat-s05">系统相关</a><br><pre>Waits for a duration in seconds. It can also wait for ports. <br><br>Arguments<br><br>The single argument can be a <a href="./index.html#numberxex">number!</a>, <a href="./index.html#blockxex">block!</a>, <a href="./index.html#nonexex">none!</a>.<br><br>Refinements<br><br> /all - Returns all events in a block.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; simple wait for 20 seconds</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> now/time<br>== 13:34:56<br>red>> wait 20 ;wait happens here<br>== none<br>red>> now/time<br>== 13:35:21<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="what"> what</span> type: unset! Categories: <a href="./index.html#cat-d02">文档</a>, <a href="./index.html#cat-h01">帮助 & 调试</a><br><pre>关键字 <a href="./index.html#what">what</a> displays brief information about every Red function,<br>one per line.<br><br>Has no arguments or refinements.<br></pre>例子<pre>red>> what<br><b style="color: blue">to : Converts to a specified datatype</b><br><b style="color: blue">not : Returns the negation (logical complement) of a value</b><br><b style="color: blue">remove : Returns the series at the same index after removing a value</b><br><b style="color: blue">while : Evaluates body as long as condition is true</b><br><b style="color: blue">any : Evaluates, returning at the first that is true</b><br><b style="color: blue">copy : Returns a copy of a non-scalar value</b><br><b style="color: blue">insert : Inserts value(s) at series index; returns series head</b><br><b style="color: blue">if : If condition is true, evaluate block; else return NONE</b><br><b style="color: blue">... a lot more lines are displayed ... omitted here</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="what-dir"> what-dir</span> type: function! Categories: <a href="./index.html#cat-f01">文件</a><br><pre>关键字 <a href="./index.html#what-dir">what-dir</a> returns the active directory path as a <a href="./index.html#filexex">file!</a> value.<br><br>It has no arguments.<br><br>Irrespective of the operating system, it uses / in file paths.<br><br>Literal file paths must start with the % sign:<br> So, e.g. c:\windows\system32 must be represented as %/c/windows/system32<br></pre>例子<pre>a: what-dir<br>== %/C/rebol/<br><br>type? a<br>== file!<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="while"> while</span> type: native! Categories: <a href="./index.html#cat-i02">迭代</a><br><pre>关键字 <a href="./index.html#while">while</a> has two arguments:<br> - a condition <a href="./index.html#blockxex">block!</a><br> - a body <a href="./index.html#blockxex">block!</a><br><br>As long as the condition <a href="./index.html#blockxex">block!</a> returns <a href="./index.html#true">true</a>, the body <a href="./index.html#blockxex">block!</a><br>will be evaluated.<br><br>NOTE that in Red, a <a href="./index.html#blockxex">block!</a> can contain several evaluations; only the value<br> resulting from the final evaluation influences the <a href="./index.html#while">while</a> condition.<br><br>关键字 <a href="./index.html#break">break</a> can be used to break out of the body <a href="./index.html#blockxex">block!</a>.<br><br>In the case where several conditions control the loop continuation, you might<br>require short-circuit evaluation of the condition using <a href="./index.html#all">all</a>.<br><br>When working with <a href="./index.html#seriesxex">series!</a>, you should investigate existing functions like<br><a href="./index.html#first">first</a>, rather than writing complex loops.<br></pre>例子<pre>count: 1<br>while [count <= 5] [<br> print count<br> count: count + 1<br>]<br>print "Done"<br>print count<br><b style="color: blue">1</b><br><b style="color: blue">2</b><br><b style="color: blue">3</b><br><b style="color: blue">4</b><br><b style="color: blue">5</b><br><b style="color: blue">Done</b><br>== 6<br><br>while [all [ n < 10 still-ok] ] [<br> body <b style="color: green">; which might alter n and/or still-ok</b><br>]<br><b style="color: green">; Either condition going false will terminate the loop.</b><br><b style="color: green">; The extra [ ] are because the condition must be inside a block.</b><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="withinxqm"> within?</span> type: function! Categories: <a href="./index.html#cat-m02">数学</a><br><pre>Return <a href="./index.html#true">true</a> if the point is within the rectangle bounds, otherwise <a href="./index.html#false">false</a>.<br><br>Arguments<br> point - a <a href="./index.html#pairxex">pair!</a> - XY position of point. Origin is at upper left corner.<br> offset -a <a href="./index.html#pairxex">pair!</a> - Offset of area, i.e. upper left corner of a rectangle.<br> size - a <a href="./index.html#pairxex">pair!</a> - Size of area, i.e. width, height of area.<br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Explore possibilities for within?, with 8x2 area, corner at 5x10</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;5x5 outside<br>red>> within? 5x5 5x10 8x2<br>== false<br><br>;12x11 inside<br>red>> within? 12x11 5x10 8x2<br>== true<br><br>;5x10 on edge, considered inside<br>red>> within? 5x10 5x10 8x2<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="wordxex"> word!</span> type: datatype! Categories: <a href="./index.html#cat-d03">数据类型</a><br><pre>To do by red-by-example team ...</pre><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br><br><br><span class="mike-large" id="wordxqm"> word?</span> type: function! Categories: <a href="./index.html#cat-t01">类型检查</a><br><pre>关键字 <a href="./index.html#wordxqm">word?</a> returns <a href="./index.html#true">true</a> if its argument is a <a href="./index.html#wordxex">word!</a> type, <br>otherwise <a href="./index.html#false">false</a>.<br><br>Its single argument can be of any type.<br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Try word? with various types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> word? "abc"<br>== false<br><br>red>> word? 123<br>== false<br><br>red>> word? abc<br>*** Script Error: abc has no value<br>*** Where: word?<br><br>'a word<br>red>> word? 'abc<br>== true<br><br>red>> word? first [abc]<br>== true<br><br>red>> x: 3<br>== 3<br><br>red>> word? x<br>== false<br><br>red>> word? :x<br>== false<br><br>red>> word? first [x]<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="words-of"> words-of</span> type: function! Categories: <a href="./index.html#cat-r01">反射</a><br><pre>Returns the list of words of a value that supports reflection. <br><br>Arguments<br><br>A value of a type that supports reflection.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; words-of, with map and object</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>;with map<br>red>> m: make map![a 1 b 2]<br><br>red>> words-of m<br>== [a b]<br><br>;with object<br>red>> place: make object! [x-pos: 100 y-pos: 200 ]<br><br>red>> words-of place<br>== [x-pos y-pos]<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="write"> write</span> type: action! Categories: <a href="./index.html#cat-d01">目录</a>, <a href="./index.html#cat-f01">文件</a>, <a href="./index.html#cat-o02">输出</a><br><pre>Writes data to a <a href="./index.html#filexex">file!</a>, <a href="./index.html#urlxex">url!</a>, or other port.<br><br>Arguments<br> 1. destination: a <a href="./index.html#filexex">file!</a> or <a href="./index.html#urlxex">url!</a><br> 2. data to write: any type.<br><br>Refinements<br> /binary - preserves contents exactly. Use for images, etc.<br> /lines - write each value in a block as a separate line.<br> /info - no details available currently<br> /append - write data at end of file.<br> /part - partial write a given number of units.<br> We provide a length, as a <a href="./index.html#numberxex">number!</a>.<br> /seek - write at a specific position. We provide a position,<br> as a <a href="./index.html#numberxex">number!</a>.<br> /allow - specifies protection attributes. We provide access <br> details in a <a href="./index.html#blockxex">block!</a>.<br> /as - write with the specified encoding, default is 'UTF-8.<br> We provide the encoding as a <a href="./index.html#wordxex">word!</a>.<br><br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Use write. Note the preceding % for literal file names.</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br><br>;write 1 line to local file testfile.txt<br>red>> write %testfile.txt "ABCDEFG"<br>;read it back<br>red>> read %testfile.txt<br>== "ABCDEFG"<br>;/seek refinement<br>red>> write/seek %testfile.txt "XXX" 2<br>;read it back<br>red>> read %testfile.txt<br>== "ABXXXFG"<br><br>; /lines refinement<br>red>> write/lines %testfile.txt ["a line" "another line"]<br>;read it back, use print to avoid console formatting<br>red>> print read %testfile.txt<br>a line<br>another line<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xor"> xor</span> type: op! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>关键字 <a href="./index.html#xor">xor</a> returns the exclusive "or" of its two arguments.<br><br>The type of both arguments can be:<br> <a href="./index.html#logicxex">logic!</a> <a href="./index.html#integerxex">integer!</a> <a href="./index.html#charxex">char!</a> <a href="./index.html#bitsetxex">bitset!</a> <a href="./index.html#typesetxex">typeset!</a> <a href="./index.html#pairxex">pair!</a> <a href="./index.html#tuplexex">tuple!</a> <a href="./index.html#vectorxex">vector!</a><br><br><a href="./index.html#xor">xor</a> provides a sensible interpretation of "true when different"<br>for types and combinations of types.<br><br>The result type is determined by the type of the first argument.<br><br>Certain combinations of types are disallowed.<br></pre>例子<pre>3 xor 2<br>== 1<br><br>3x3 xor 2x2 ;pairs<br>== 1x1<br><br>3x0 xor 3x1<br>== 0x1<br><br>#"A" xor 2 ;character, number<br>== #"C"<br><br>2 xor #"A"<br>== 67<br><br>#"A" xor 2<br>== #"C"<br><br>true xor false<br>== true<br><br>true xor true<br>== false<br><br>3 xor 2x1<br>*** Script error: xor does not allow pair for its value2 argument<br>*** Where: xor<br><br>123 xor true<br>*** Script error: logic type is not allowed here<br>*** Where: xor<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="xorxsn"> xor~</span> type: action! Categories: <a href="./index.html#cat-b02">位操作</a><br><pre>Returns the exclusive OR of its 2 arguments.<br><br>It is the functional equivalent of the <a href="./index.html#xor">xor</a> infix operator.<br><br></pre>例子<pre><b style="color: green">; -------------------------------------------------------------------------</b><br><b style="color: green">; Explore some types</b><br><b style="color: green">; -------------------------------------------------------------------------</b><br><br>red>> xor~ 3 3<br>== 0<br>red>> xor~ 1 3<br>== 2<br><br>red>> xor~ #"A" 1<br>== #"@"<br>red>> xor~ #"D" 1<br>== #"E"<br><br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="yes"> yes</span> type: logic! Categories: <a href="./index.html#cat-b03">布尔</a>, <a href="./index.html#cat-c05">常量</a><br><pre>The value <a href="./index.html#yes">yes</a> can be used as the boolean value <a href="./index.html#true">true</a>.<br></pre>例子<pre>red>> yes<br>== true<br><br>red>> not yes<br>== false<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><br><br><span class="mike-large" id="zeroxqm"> zero?</span> type: function! Categories: <a href="./index.html#cat-c02">比较</a><br><pre>关键字 <a href="./index.html#zeroxqm">zero?</a> returns <a href="./index.html#true">true</a> if its argument is zero; <br>otherwise <a href="./index.html#false">false</a>.<br><br>Has one argument: a <a href="./index.html#numberxex">number!</a> or a <a href="./index.html#pairxex">pair!</a>.<br></pre>例子<pre>zero? 3<br>== false<br><br>zero? 3.1<br>== false<br><br>zero? 0<br>== true<br><br>zero? 2x0<br>== false<br><br>zero? 0x0<br>== true<br><br><a href="./index.html#top">顶部</a> <a href="./index.html#ix-alpha">字母索引</a> <a href="./index.html#ix-cat">分类索引</a><br><br></pre><!----------------------------------------------------------------------------></td></tr></tbody></table></center>
<iframe id="flower-password-iframe" src="./index_files/iframe.html" style="display: none; width: 274px; height: 207px; left: 0px; top: 0px;"></iframe></body></html>