World: r3wp
[Core] Discuss core issues
older newer | first last |
Gabriele 19-Dec-2009 [15282] | Re: IT - the problem in looking up the stack is knowing which argument to look it up. I guess the first would work and be useful enough, though. |
Paul 19-Dec-2009 [15283] | 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 ] |
Henrik 19-Dec-2009 [15284] | array/initial? |
Paul 19-Dec-2009 [15285x3] | no as that would just put the initial values in the series |
This function returns a copy of everything until it finds the value specified and then it breaks. | |
Seems such usefulness that it would be built in - so I keep thinking I'm missing something. | |
Henrik 19-Dec-2009 [15288x2] | you can do that with copy/part, as long as the /part is the same block |
a: [b c d] copy/part a find a 'd == [b c] | |
Paul 19-Dec-2009 [15290] | Steeve, I love your thinking about the pop function. I have wanted that feature before for operators myself. |
Henrik 19-Dec-2009 [15291] | it must be the same block, not just an identical one |
Paul 19-Dec-2009 [15292x2] | yeah Henrik, I'm suprised that we need to combine functions though to achieve that. |
I guess that is my point. I would think we simply would have one function that does that. | |
Henrik 19-Dec-2009 [15294] | well, this allows you to put together any condition for the item you want to stop at, so I think it's OK. it's something else, if the code pattern occurs very often (never used this one). |
Paul 19-Dec-2009 [15295x2] | Yeah that is fine Henrik. |
wha tis the suffix-map in REBOL used for? | |
Steeve 19-Dec-2009 [15297x3] | Brian, even if the Rebol's VM is not a true stack machine. It has a data stack, so that, the POP function could be emulated in some way. A forth kernel, is nothing else than that. To simulate a stack machine on a processor that is not designed that way initially. However, your response suggests that the cost would be high. |
If it was possible, the 'IT function could be emulated like this: IT: does [push pop] ; pop the and repush the last stacked value (just to read it without modifying the stack). | |
With R3, currently we can do... >> it: does [first stack/args 2] >> if 1 + 1 [print it] 2 | |
BrianH 19-Dec-2009 [15300x5] | IT would need to search up the stack to find the nearest appropriate function call frame - it doesn't just apply to the next call up. |
Gabriele, UNLESS has been around for many years - just not used by many people because of personal preference. They used the slower IF NOT instead. | |
Paul, you won't need stack tricks to get user-defined operators in R3 - we'll just use user-defined op! functions. | |
The reason Steeve's proposal doesn't work is because the result of the prior expression is thrown away, not pushed on a stack. | |
Oh, and suffix-map is used by the codec system, afaik. | |
Rebolek 19-Dec-2009 [15305] | Brian, Steeve's examp;e works, you just have to do >>secure none |
BrianH 19-Dec-2009 [15306] | Sorry Bolek, I should have been more specific. I meant Steeve's POP proposal and the CONCAT example wouldn't work (for reason's stated above). Gabriele's IT proposal and Steeve's sample implementation of it would work a little, but would need modification. |
Gabriele 20-Dec-2009 [15307] | Brian, how many scripts on rebol.org use the result of UNLESS? |
Sunanda 20-Dec-2009 [15308] | There are 45 scripts on FREBOL.org that appear to use UNLESS (there may be a few false positives in this -- if, say, the word UNLESS has been reused): http://www.rebol.org/search.r?find=unless+[b] |
Gabriele 22-Dec-2009 [15309] | and, how many of them do something like: var: unless ... |
Rebolek 3-Jan-2010 [15310] | I was reading http://www.chalicegames.com/swym/SwymWebIntro.html and some concepts were interesting to me(especially ETC), so I made REBOL equivalents: http://box.lebeda.ws/~rebolek/rebol/swyv.r There's a documentation in the script, so just few examples of what it can do: SERIE: >> serie [etc 1 2 4 .. 20 cycle [1 2 3] length 5 iterate [x: x + 10] from 10 5] == [1 2 4 8 16 1 2 3 1 2 10 20 30 40 50] COMPARE: a: [1 2 3 4 5 6 7 8 9] b: [2 4 6] >> compare a b [some a > every b] == true >> compare a b [one a > every b] == false FILTER: >> filter serie [iterate [x: x + 1] 10 ] [[x > 2] [x < 5]] == [3 4] >> filter etc [3 6 9] 100 [x > 250] == [252 255 258 261 264 267 270 273 276 279 282 285 288 291 294 297 300] >> filter serie [1 .. 10] [[x > 5][zero? x // 2]] == [6 8 10] It's written in R3 but should also work in R2 (not tested). It's not optimized so if you're interested in it, feel free to do whatever you want to improve it (more patterns that ETC can recognize...). |
Gregg 3-Jan-2010 [15311] | Cool Bolek. |
Dockimbel 3-Jan-2010 [15312] | Rebolek: thanks for the link, lots of good food for thought here. That would be great to support it at native level (using a R3 extension). I also wonder how much of it could be implemented efficiently using 'map-each and 'apply. Anyway, this could be a really great addition to R3 (or even R2). Keep up the good work. |
BrianH 3-Jan-2010 [15313] | The REBOL equivalent of the functional-language operation fiter is REMOVE-EACH. |
Rebolek 3-Jan-2010 [15314x2] | Brian: FILTER is REMOVE-EACH on steroids. Gregg, Doc: Thanks! What I'm working on right now is this: divisor: func [x][filter serie [1 .. x][zero? x // i]] prime?: func [x][equal? 2 length? divisor x filter [1 .. 50][prime? x] this must work. |
well, add the missing "]" ;) | |
BrianH 3-Jan-2010 [15316] | I was talking about the functional-language filter operation, not Bolek's (much cooler) FILTER :) |
Steeve 3-Jan-2010 [15317] | Well it's interesting as a study dialect. But to be honest guys, i don't see the interest to have them in Rebol. Because we can do much of the use cases rebolek showed us with one or two lines of rebol code. And i don't need to say that it will got lightning speed by comparison But anyway, It's lot of fun to do such things with Rebol. |
Gregg 4-Jan-2010 [15318] | I think that's the point Steeve. Looking for new ways to express things, that may be useful, and may inspire more useful adaptations. |
Graham 4-Jan-2010 [15319] | spell: func [ check [string!] /local req result suggestions ][ req: reform compose copy [ <spellrequest textalreadyclipped="0" ignoredups="1" ignoredigits="1" ignoreallcaps="0"> <text> (check) </text> </spellrequest> ] result: load/markup read/custom https://www.google.com/tbproxy/spell reduce [ 'POST req ] either parse result [ tag! tag! tag! set suggestions string! tag! tag! end ][ parse suggestions none ] [ none ] ] >> spell "rebol" connecting to: www.google.com == ["reboil" "rebel" "reboils" "Reebok" "rebook"] |
Anton 4-Jan-2010 [15320] | Bolek, that's very interesting for me because I was searching for just such a declarative dialect for sound generation and music composition. |
Pekr 4-Jan-2010 [15321] | Anton - still experimenting with sound? Maybe R3 Extension based on fmod is waiting for you to bring it to REBOL? :-) |
Rebolek 4-Jan-2010 [15322] | Anton, I'm glad to hear that. In which way are you interested to use it in sound/music generation? One of my first thoughts was howe to use this together with Sintezar. It should probably be used for oscillator wavetables generation... I'm not sure. |
Pekr 4-Jan-2010 [15323] | Rebolek - do vectors help you with sounds? There are some high-priority changes planned for vectors for the 3.0 beta IIRC. |
Rebolek 4-Jan-2010 [15324] | Pekr, vectors are really great. But they need few improvements and bugfixes here and there. I wrote a document what doesn't work and should some time ago (has been two years already? I think so). I haven't looked at them recently, so maybe they're improved already. I should check my R3 AIFF/WAV loaders/savers wheter they work as they have been the best test for vectors I had. |
Pekr 4-Jan-2010 [15325x2] | High priority for Vector says - Basic vector! conversions and ops ... dunno how Carl sticks to the published project plan though ... |
Whole document is here - http://rebol.com/r3/docs/project.html.... there are even some sound related changes planned, although with lower priority ... | |
Pavel 4-Jan-2010 [15327] | Rebolek How much differ vectors from binary in sound application isn't it pure record of numbers only? |
Rebolek 4-Jan-2010 [15328] | Pavel, yes it is. But you can say that binary! is subset of vector! - 8bit unsigned vector. With vector! You can generate for example 16bit signed stream and then just add WAV/AIFF header. So vector! is superior to binary! from this point of view. |
Gregg 4-Jan-2010 [15329] | Very nice Graham! |
james_nak 5-Jan-2010 [15330] | Smart guys. This may seem elementary but I need to check if certain ports are open on a windows machine. For example, port 8881. I use something like error? try [close open to-url "tcp://:8881"] (building these strings with various port numbers). My problem is I don't know how to check if it is working. I turn on the firewall and it doesn't seem to make a difference. Perhaps my thinking is all wrong and all I am doing is checking within the firewall. Any thoughts? |
Graham 5-Jan-2010 [15331] | all that does is trying to open a server port |
older newer | first last |