AltME groups: search
Help · search scripts · search articles · search mailing listresults summary
world | hits |
r4wp | 237 |
r3wp | 1294 |
total: | 1531 |
results window for this page: [start: 901 end: 1000]
world-name: r3wp
Group: Core ... Discuss core issues [web-public] | ||
Geomol: 22-Aug-2009 | Anton, ah, but my function doesn't work with other action! values anyway: >> a?: func [:value] [action! = type? value] >> a? first ** Script Error: value expected series argument of type: series pair event money date objec t port time tuple any-function library struct ... Trying dobble get-word! : >> a? :first == false So maybe this doesn't work with any action! datatype? | |
Sunanda: 28-Aug-2009 | Is my understanding of find/part wrong, or is this a bug? series: ["a" "b" "c" "d" "e"] find/part series "c" at series 3 == none ;; fails to match using the [at series 3] part of 'series print mold at series 3 == ["c" "d" "e"] ;; but [at series3] does contain the match | |
Dockimbel: 28-Aug-2009 | The /part <range> argument (at series 3) is supposed to mark the end of the search range. So, here FIND is searching in ["a" "b"] only. | |
Dockimbel: 28-Aug-2009 | >> find/part series "c" 3 == ["c" "d" "e"] >> find/part series "c" at series 3 == none >> index? at series 3 == 3 This looks like an inconsistency to me. | |
Sunanda: 28-Aug-2009 | Thanks. What was confusing me is an inconsistency between R2 and R3 -- was not sure if R3 was the bug fix or the problem. R2: select/part series "c" at series 4 == "d" R3: >> select/part series "c" at series 4 == none *** Do we agree R3 is right in this case? | |
BrianH: 7-Sep-2009 | In R3: >> help swap USAGE: SWAP series1 series2 DESCRIPTION: Swaps elements of a series. (Modifies) SWAP is an action value. ARGUMENTS: series1 (series! gob!) series2 (series! gob!) >> swap a: "abc" skip a 2 a == "cba" | |
Ashley: 10-Sep-2009 | Also, the help text for as-string says "Coerces any type of string ...". Should that read "any type of series"? | |
Maxim: 17-Sep-2009 | this value is only the basis for an intense series of string manipulations which make even the original data useless unless someone has the exact algorythm which generated the key. | |
Dockimbel: 4-Oct-2009 | From the script header: Purpose: "Working around string series"...I think that this is shooting yourself in the foot. | |
Dockimbel: 8-Oct-2009 | IIRC, Carl explained (at least) once that this behaviour is different on purpose. Using path notation with an index value or PICK should return NONE while using the prefix notation FIRST, SECOND,...LAST should return an error. So you have the choice to either silently handle missing values in series or raise an error!. | |
Maxim: 30-Oct-2009 | found a bug in 'FOR when used in series... it becomes an endless loop.. | |
Geomol: 16-Nov-2009 | It is a bit confusing, also because both path! and file! are series, so it's easy to think, they should work the same. >> series? d == true >> series? %/a/b/c == true | |
Geomol: 16-Nov-2009 | A question: can it be justified, that file! is a series? >> a: %/c == %/c >> first a == #"/" >> a/1 == %/c/1 Is file! a pseudo-series? What exactly defines a series? It's some sort of a sequence of values, that can be picked individually. And series can be sorted, right? So the methods (or functions), that can be performed on the datatype defines its type. What defines a series in REBOL? | |
Maxim: 16-Nov-2009 | each series type handles path actions how it wants to. | |
Maxim: 16-Nov-2009 | files append to themselves, blocks do lookup, strings return chars. to be a series, in has to support insert, copy, first which is why tuple isn't a serie. | |
BrianH: 16-Nov-2009 | Geomol: "What defines a series in REBOL?" A series has contents, sequence and persistent position. The characters that make up a file (contents) are in a specific order (sequence) and you can do an offset reference to a later offset in the filename (position). If you do FIRST %a it will return #"a" every time (persistent position). Being a series doesn't mean that it is sortable, though many are. Being sortable means also having the contents be comparable, and the series be modifiable. We were careful to make sure that things that aren't really series-like were removed from the series! typeset in R3. R2 is less consistent in this regard, so you have some types attempting to act series-like, poorly - pots being the worst example. Some of the functions that act on series also act (differently) on non-series, but not all. | |
Maxim: 16-Nov-2009 | I thought that to qualify to be a series, a type also needed to support insertion, not only indexing and content. cause your above definition qualifies tuple! to be a series, but they aren't. | |
BrianH: 16-Nov-2009 | Position: HEAD, TAIL, HEAD?, TAIL?, AT, SKIP, NEXT, BACK Contents: PICK, POKE (for modifiable series), ordinals (FIRST, ..., LAST) Sequence: PICK and POKE can use numbers (used to implement ordinals) Persistent position and sequence: All of the above are repeatable, with no position change side effect. | |
BrianH: 16-Nov-2009 | LENGTH? too. Note that in R3 an image! counts as a series, though it has 2 different position measures. | |
BrianH: 16-Nov-2009 | Ports in R3 (or open/direct or command ports in R2) don't have persistent position and sequence, or reference position. This makes them streams, not series. | |
Maxim: 16-Nov-2009 | yes basically, they are always at position 0 and looking at the data, implies you remove it, so ports are like quantum series ;-) | |
BrianH: 16-Nov-2009 | The reference position vs inherent position distinction is important. That is why the position functions are seeking procedures for ports, while they are pure reference-returning functions for series. | |
Chris: 16-Nov-2009 | It'd still be nice to have an interface that in some ways behaved like R2 ports (I think of it as adapter!) that allow the above series functions to operate on customised, abstracted series. Perhaps I'm overlooking a simpler way of addressing the problems I have in mind. | |
Geomol: 2-Dec-2009 | I often find myself thinking about, how to categorize REBOL among other programming languages. I think, it's how the language wants us to make sentences and not just give commands, one on each line. In REBOL, we write: insert back tail series my-value and it feels natural. In other languages, you would do something like: int sz = length (series); Series *ptr = &series[sz - 1]; insert (ptr, my_value); You could maybe do: insert ( &series[length (series) - 1], my-value); but it's just far from being as elegant as in REBOL. So most languages are like simple commands all the time, one after each other. With REBOL we make sentences. It's like a huge step up from many traditional programming languages. | |
Gregg: 2-Dec-2009 | Even with a simple example like the one you gave, I might add a couple funcs to make the intent even clearer. e.g. insert-from-tail: func [ series [series!] value index [integer!] ] [ insert skip tail series negate abs index value ] insert-before-tail: func [ series [series!] value ][ insert-from-tail series value 1 ] insert-before-tail series my-value | |
Paul: 19-Dec-2009 | Isn't something like this code already built-in in REBOL and I'm just missing it: copy-to: func [series [series!] arg /local cpd d][ cpd: make type? series 10 foreach item series [ either not-equal? arg item [insert tail cpd item][break] ] cpd ] | |
Paul: 19-Dec-2009 | no as that would just put the initial values in the series | |
Gregg: 15-Jan-2010 | And in this case, it's easy to try and see if you like it. length??: func [series [series! none!]] [ all [series length? series] ] | |
ChristianE: 20-Jan-2010 | Everytime I'm writing (slow, but short) code like >> unique append series 'value or (very fast, but wordy) >> any [find series value insert series value] >> unless find changes 'weight [insert changes 'weight] I'm wondering whether there's a nicer way to insert a value into a series only if it isn't in there yet. Something in the same line as ALTER. This just reeks like the perfect situation for some Guru O'Brian or Gabriele D'Enciclopedia to point out that there's already a REBOL native which provides exactly that functionality ;-) On a unrelated side note, I'm wondering if ALTER is missing an /ONLY refinement, too: >> alter series: [] [1 2] series == [1 2] >> alter/only series: [] [1 2] series ** Script Error: alter has no refinement called only ** Near: alter/only series: [] [1 2] series Would that be worth adding to R3, I'm thinking about ticketing it as a wish in CureCode? | |
ChristianE: 20-Jan-2010 | INCLUDE in R3 is not a global word, in the code im currently writing >> include package/changes 'weight reads very nice. Sadly, it's signature wouldn't be compatible with EXCLUDE, which only allows series and sets as it's second argument. The two refinements /INCLUDE and /EXCLUDE though would make ALTER more usefull. | |
BrianH: 21-Jan-2010 | >> spec-of :remove-each == [ {Removes values for each block that returns true. Returns remove count. (Modifies)} 'word [word! block!] "Word or block of words to set each time (local)" data [series!] "The series to traverse" body [block!] "Block to evaluate (return TRUE to remove)" ] | |
BrianH: 25-Jan-2010 | It will tell you evaluations and series created, which is a bit more cross-platform reliable than time. Don't know how fast your CPU is. | |
Gregg: 27-Jan-2010 | forskip+: func [ "Like FORSKIP, but with local FIRST? and LAST? support." [throw catch] 'word [word!] {Word set to each position in series and changed as a result} skip-num [integer!] "Number of values to skip each time" body [block!] "Block to evaluate each time" /local orig result ][ if not positive? skip-num [throw make error! join [script invalid-arg] skip-num] if not any [ series? get word port? get word ] [ throw make error! {forskip/forall expected word argument to refer to a series or port!} ] orig: get word use [first? last?] [ first?: true last?: false body: bind/copy body 'first? while [any [not tail? get word (set word orig false)]] [ if tail? skip get word skip-num [last?: true] set/any 'result do body set word skip get word skip-num first?: false get/any 'result ] ] ] | |
BrianH: 30-Jan-2010 | single?: funco [ "Returns TRUE if the series length is 1." series [series! port! tuple! bitset! struct!] ; map! object! gob! any-word! ][1 = length? :series] ; Note: Type spec same as LENGTH?, which also supports the extra types in R3 | |
Gregg: 20-Feb-2010 | I have ALTERNATE and MERGE at the lower levels. The first combines two series and returns a new series. The second merges one series into another, with a /SKIP refinement. I have TO-SPEC-BLOCK , since that's such a useful and common need. I avoided using AS- in the past, thinking more standard non-copying coercion funcs would make them confusing. Those haven't appeared, so I do use AS- sometimes now. | |
Maxim: 26-Feb-2010 | I also often use a FILTER function which is just a wrapper around remove-each which does a copy on the source input and adds a NOT to the comparison block you provide. this means you keep data instead of removing it and don't break the original series. | |
Steeve: 26-Feb-2010 | Actually, it's so easy to add a copy where you need, that i think all the serie's constructing native functions should update the input by default, rather than construncting new ones. Think About UNION, UNIQUE, INTERSECT etc... They are handy functions but involve too much overhead on big series. | |
Maxim: 26-Feb-2010 | I would love the /INTO refinement be added to all series manipulators. This way we can make a huge buffer and reuse it all the time. | |
Maxim: 26-Feb-2010 | much less work for the GC and big speed gains on large series. | |
BrianH: 28-Feb-2010 | Yeah, the position being an attribute of the reference is one of the core parts of series behavior in REBOL. In contrast, in R3 ports the position is an attribute of the port, not the reference to the port; same with OPEN/direct ports in R2. | |
BrianH: 28-Feb-2010 | This means that SKIP is a pure function for series, returning a reference to a new position - while it is modifying when applied to ports, changing the internal position. Same with the other position functions like AT, HEAD and TAIL. | |
ChristianE: 28-Feb-2010 | I know such things when writing code, but more in a subconcious way. Of course different references to the same block having different positions doesn't go together with position being an attribute of the block (series) itself. That's of course obvious after only a little amount of thinking ;-) | |
Ashley: 4-Apr-2010 | A non-parse solution (for the replace problem) based on the existing replace mezz: replace-each: make function! [ target [series!] "Series that is being modified" values [block!] "Block of search/replace strings" /local len pos ][ foreach [search replace] values [ len: length? search while [pos: find target search] [ target: change/part pos replace len ] ] ] | |
Ashley: 19-Apr-2010 | As long as the first argument is a series ... | |
BrianH: 20-Apr-2010 | Series, or map or object. | |
Maxim: 23-Apr-2010 | its a shame cause looping a large list manually and comparing with same? is VERY slow :-( on a 10 million sized series. my fastest FIND-SAME loop is 20 time slower than FIND, which would be much faster, since all it would have to do is compare a pointer. | |
Maxim: 23-Apr-2010 | here's my fastest one yet... I tried two so far... ;----------------- ;- find-same() ;----------------- find-same: func [ series [block!] item [series! object!] /local s i ][ i: 1 repeat s series [ i: i + 1 if same? s item [ break ] ] unless i > length? series [ at series i - 1 ] ] using until was slower probably because REPEAT is faster than UNTIL (no exit condition or series index to increase). | |
sqlab: 23-Apr-2010 | How about combining find with a loop find-same: func [ series [block!] item [series! ] /local s ][ while [s: find series item] [ if same? first s item [return true] series: next s ] false ] | |
Sunanda: 9-May-2010 | You mean using /skip and /compare to sort a series in sets? s: [1 2 8 a 1 2 6 b 1 2 7 c] ;; three sets of four items sort/skip/compare s 4 [3] ;; sort on the third item == [1 2 6 b 1 2 7 c 1 2 8 a] | |
Henrik: 9-May-2010 | since tuple are not series in R3, then I'd say it's fixed. | |
Maxim: 10-May-2010 | they aren't series. | |
Terry: 17-May-2010 | ok, one last one for my rusty rebol FINDing the index of all occurences of an integer in a series ie: blk: [ 239 4545 23 655 23 656[ search for 23 and return [3 5] (not using foreach) | |
Ladislav: 17-May-2010 | indices?-1: func [ series [series!] value /local result ] [ result: make series 0 while [series: find series value] [ append result index? series series: next series ] result ] indices?-2: func [ series [series!] value /local result ] [ result: make series 0 parse series [ any [1 1 value series: (append result subtract index? series 1) | skip] ] result ] >> time-block [indices?-1 blk 23] 0,05 == 0.000006591796875 >> time-block [indices?-2 blk 23] 0,05 == 0.000005645751953125 | |
Pekr: 17-May-2010 | Hmm, my version is much slower: indices?-3: func [ series [block!] value [integer!] /local result ][ result: make series 0 parse series [ any [s: set wanted integer! (if value = wanted [append result index? s])] ] result ] >> time-block [indices?-1 blk 23] 0,05 == 0.000004669189453125 >> time-block [indices?-2 blk 23] 0,05 == 0.0000039520263671875 >> time-block [indices?-3 blk 23] 0,05 == 0.0000059661865234375 | |
Pekr: 17-May-2010 | A bit adapted Lad's version (does not use substraction): indices?-4: func [ series [series!] value /local result ] [ result: make series 0 parse series [ any [series: 1 1 value (append result index? series) | skip] ] result ] >> time-block [indices?-2 blk 23] 0,05 == 0.000003936767578125 >> time-block [indices?-4 blk 23] 0,05 == 0.000003753662109375 | |
Pekr: 17-May-2010 | Replacing "1 1 value" by "quote (value)" as variant 5: indices?-5: func [ series [series!] value /local result ] [ result: make series 0 parse series [ any [series: quote (value) (append result index? series) | skip] ] result ] >> time-block [indices?-1 blk 23] 0,05 == 0.0000047607421875 >> time-block [indices?-2 blk 23] 0,05 == 0.000003936767578125 >> time-block [indices?-3 blk 23] 0,05 == 0.0000059814453125 >> time-block [indices?-4 blk 23] 0,05 == 0.00000372314453125 >> time-block [indices?-5 blk 23] 0,05 == 0.000003692626953125 | |
Terry: 17-May-2010 | >> a == [23 43 55 28 345 99 320 48 22 23 95 884 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999... >> (a is a block with 1, 000,012 integers) ind: func[series value x][ st: now/time/precise while [x > 0][ result: make series 0 series: head series parse series[any [series: 1 1 value (append result index? series) | skip]] x: x - 1 ] et: now/time/precise fin: et - st print fin result ] feach: func[series value x][ result: make series 0 st: now/time/precise while [x > 0][ foreach[s p v] series [if s = value [append result reduce [s p v]]] x: x - 1 ] et: now/time/precise fin: et - st print fin result ] >> ind a 23 10 0:00:01.249 == [1 10 999990] >> >> feach a 23 10 0:00:01.01 == [23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 95 884 23 43 55 23 9... >> 10 iterations each.. foreach is the winner speed wise.. as a bonus, If i use foreach, I don't need the index? | |
Maxim: 17-May-2010 | in your tests, this causes your loops to slow down a lot: result: make series 0 you should: result: make series length? series. because when appending, you will be re-allocating the result over and over... and the GC is the loop killer in every single big dataset tests I've done. not because its bad, per se, but because you are forcing it to operate. | |
Terry: 17-May-2010 | moving the result: make series 0 out of the while loop had a 10 milli improvement over 10 iterations. | |
Maxim: 17-May-2010 | find-fast: func [ series value record-length i "iterations" /local result st s ][ st: now/precise while [i > 0][ result: make series 0 ;length? series s: head series until [ not if s: find s value [ either 0 = mod -1 + (index? s) record-length [ insert tail result copy/part series record-length not tail? s: next s ][ s: next s ] ] ] i: i - 1 ] print difference now/precise st print length? result result ] | |
Andreas: 17-May-2010 | indices?-maxim-1: func [series value /local result][ result: make block! length? series until [ not if series: find series value [ append result index? series series: next series ] ] result ] | |
Andreas: 17-May-2010 | not if series: find/tail series value [ append result (index? series) - 1 ] | |
Andreas: 17-May-2010 | indices?-3: func [series value /local result][ result: make block! length? series until [ not all [ series: find/tail series value append result (index? series) - 1 ] ] result ] | |
Andreas: 17-May-2010 | the kernel of the C extension: result = RXI_MAKE_BLOCK(series_n - series_i); result_n = 0; for (; series_i < series_n; ++series_i) { elem_type = RXI_GET_VALUE(series, series_i, &elem); if (elem.int64 == value.int64 && elem_type == value_type) { result_v.int64 = series_i + 1; RXI_SET_VALUE(result, result_n++, result_v, RXT_INTEGER); } } | |
Pekr: 18-May-2010 | btw - will there be any difference between: result: make block! length? series and result: make series 0 I mean - e.g. not prealocating large enough series (make series 0) will be slowed down by GC constantly increasing the size? | |
Ladislav: 18-May-2010 | there are many important differences: *make series 0 does not necessarily make a block *regarding the allocation length - if you can estimate reliably the necessary length, then you are better off | |
Henrik: 2-Jul-2010 | what's the quickest way to determine whether a series is past end in R2 and then handle it? | |
Geomol: 2-Jul-2010 | As a side note, I noticed, TAIL? and EMPTY? is the same. So you can also write the above as: and series? s empty? s Is it wise, that TAIL? and EMPTY? does the same? Maybe EMPTY? should return false, if the series holds elements, even if you're at the tail. | |
BrianH: 2-Jul-2010 | Henrik, can you post some code that will make a series reference that is past the end of a series? I'm having trouble making one that works consistently, and neither your INDEX? method or EMPTY? will work. REBGL keeps adjusting the index returned by INDEX?. | |
BrianH: 2-Jul-2010 | In R3 they stay consistent, and there is an action PAST? to tell whether an index is past the end. >> b: next a: "a" == "" >> remove a == "" >> index? b == 2 ; not adjusted >> past? b == true In R2 I don't even see how to write this in mezzanine without temporarily appending something on the end of the series (a single element will do) and seeing if the index adjusts, then removing what you appended. Like this: >> b: next next next a: "abc" == "" >> clear a == "" >> also (index? b) < (append b "1" index? b) clear back tail b == true ; past end >> b: "" == "" >> also (index? b) < (append b "1" index? b) clear back tail b == false ; not past end, but Henrik's method, and EMPTY? will both return true. | |
BrianH: 2-Jul-2010 | Here's the source to the backport: past?: func [ "Returns TRUE if a series index is past its tail." series [series!] ; gob! port! ][ also (index? :series) < (insert tail :series "1" index? :series) clear back tail :series ; Undo the modification ] ; Note: Native in R3, and non-modifying. No ports because you can't undo the ; insert. INDEX? doesn't stay consistent with past-tail references in R2. | |
Henrik: 2-Jul-2010 | I'm not sure I would want the series to be modified as the case where PAST? is true could be for an indication of the series in a debug UI, rather than the actual use of the series. Interesting that you had so much trouble producing the problem. | |
BrianH: 2-Jul-2010 | You are also removing an element before the index, but not from the beginning. Apparently clearing from somewhere other then the beginning of the series breaks the auto-adjusting (which shouldn't be happening anyways). PAST? works the same either way. | |
Ladislav: 3-Jul-2010 | past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ (index? :series) = (index? back :series) ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
Ladislav: 3-Jul-2010 | correction: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ not same? head? :series :series (index? :series) = (index? back :series) ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
Ladislav: 3-Jul-2010 | Yet another variant: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ (index? :series) = (length? head :series) not same? tail? :series :series ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
Ladislav: 3-Jul-2010 | past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ and~ (index? :series) = (length? head :series) not same? tail :series :series ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
Ladislav: 3-Jul-2010 | Simplification: past?: func [ "Returns TRUE if a series index is past its tail." series [series! gob! port!] ][ not same? :series skip :series 0 ] ; Note: INDEX? doesn't stay consistent with past-tail references in R2. | |
BrianH: 3-Jul-2010 | To get a past-tail reference that auto-adjusts, clear from the head of the series rather than from further along. | |
Ladislav: 3-Jul-2010 | every past-tail series auto-adjusts in ceratain interpreter versions (in other no past-tail series auto-adjusts), no exceptions | |
Ladislav: 3-Jul-2010 | Henrik does not know any series that does not auto-adjust, it is just your error | |
BrianH: 3-Jul-2010 | In 2.7.7, indexes auto-adjust if you clear the series from the beginning, but not if you clear from later on. In the same interpreter. | |
Ladislav: 3-Jul-2010 | You are getting the same results you got before, it was just your error, resulting from the fact, that auto-adjustment adjusts past-tail series to tail indices, i.e. to 2 in case Henrik posted | |
Ladislav: 3-Jul-2010 | E.g. this modification works regardless of auto-adjustment: (i.e. even in R3) past?: func [ "Returns TRUE if a series is past its tail." series [series! gob! port!] ] [ and~ greater-or-equal? index? :series index? tail :series not same? :series tail :series ] | |
Ladislav: 3-Jul-2010 | BTW, "returns true if a series index is past its tail" mixes different datatypes - series index is integer, while tail is a series, so, my opinion is, that the shorter wording is less misleading | |
BrianH: 3-Jul-2010 | The not same? :series skip :series 0 line works well enough, afaict. Do you have a case for which it doesn't work and the larger test is required? | |
Ladislav: 3-Jul-2010 | Yes, but skip :series 0 auto-adjusts still, but, as I said, I do not mind | |
Ladislav: 3-Jul-2010 | (comparing series index - an integer, to series tail - a series) | |
Ladislav: 3-Jul-2010 | OK, nevermind, I do not want the text to be longer, a "series is past its tail" looks better to me, than any reference to series index | |
Ladislav: 3-Jul-2010 | , and it relates to the problem better, since in the case below: >> b == ** Script Error: Out of range or past end what is past tail is just the series not any "series index", which should be an integer value, and as such it cannot be "past tail" | |
Ladislav: 4-Jul-2010 | I adjusted the http://en.wikibooks.org/wiki/REBOL_Programming/Language_Features/Series article to mention the past-tail series and to explain differences between series with fast indexed access and series with fast insert/remove operations. | |
Maxim: 14-Jul-2010 | thing is load isn't the counterpart to mold. 'DO is. and even then, even MOLD/ALL isn't a real serialization because shared objects, or series aren't shared anymore. although they go a long way, and I have been using them extensively in many tools, MOLD & MOLD/ALL are just helpers, destined for advanced users who have very special requirements. | |
Maxim: 14-Jul-2010 | we need to build a REAL serialization dialect, one which rebuilds the data sharing, even in nested and co-occuring references to series and objects. | |
Maxim: 14-Jul-2010 | as usually, all datatypes would need to support this extended format, but since it would be managed directly within the native datatype handling it would be MUCH faster than if we tried to build some dialect for it in REBOL. especially since the native has much more direct access to things like same?, and internal states like series index. | |
Graham: 23-Jul-2010 | foreach allows you to step through a single series one at a time. So, how would you step thru more than one series at a time? a: [ n elements ] b: [ n elements ] foreach [ ofa ofb ] reduce [ a b ] [ ] ? | |
Graham: 13-Aug-2010 | Is this helpful? >> trim none ** Script Error: trim expected series argument of type: series port ** Near: trim none | |
Graham: 19-Aug-2010 | Actually I wonder why find/any shouldn't work on series like these | |
Graham: 19-Aug-2010 | >> help find USAGE: FIND series value /part range /only /case /any /with wild /skip size /match /tail /last /reverse | |
Gregg: 19-Aug-2010 | Not sure how /match is going to help you here. It only matches the start of the series. >> find/match ["Aa" "Bb" "Cc"] ["Bb"] == none >> find/match ["Aa" "Bb" "Cc"] ["Aa" "Bb"] == ["Cc"] | |
BrianH: 26-Aug-2010 | Here's the R2 version: extract: func [ "Extracts a value from a series at regular intervals." [catch] series [series!] width [integer!] "Size of each entry (the skip)" /index "Extract from an offset position" pos "The position" [number! logic! block!] /default "Use a default value instead of none" value "The value to use (will be called each time if a function)" /into "Insert into a buffer instead (returns position after insert)" output [series!] "The buffer series (modified)" /local len val ][ if zero? width [return any [output make series 0]] ; To avoid an infinite loop len: either positive? width [ ; Length to preallocate divide length? series width ; Forward loop, use length ][ divide index? series negate width ; Backward loop, use position ] unless index [pos: 1] either block? pos [ if empty? pos [return any [output make series 0]] ; Shortcut return parse pos [some [number! | logic! | set pos skip ( throw-error 'script 'expect-set reduce [[number! logic!] type? get/any 'pos] )]] unless into [output: make series len * length? pos] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [forall pos [ if none? set/any 'val pick series pos/1 [set/any 'val value] output: insert/only output get/any 'val ]] ][ unless into [output: make series len] if all [not default any-string? output] [value: copy ""] ; R2 PARSE doesn't work well for binary!, so spoof a string!. if binary? series [series: as-string series] forskip series width [ if none? set/any 'val pick series pos [set/any 'val value] output: insert/only output get/any 'val ] ] either into [output] [head output] ] |
901 / 1531 | 1 | 2 | 3 | 4 | 5 | ... | 8 | 9 | [10] | 11 | 12 | 13 | 14 | 15 | 16 |