Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 2019 22:59
    @dockimbel banned @SmackMacDougal
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
nedzadarek
@nedzadarek

ps. I've tried something like this:

  append/only tabs/pane/(index? find tabs/data "dynamic")/pane [
          text "next color"
]

but it says invalid face type.

Vladimir Vasilyev
@9214
?
view [
  tabs: tab-panel 400x400 [
     "something" [base red] 
     "dynamic" [
        button "add" [append face/parent/pane layout/only [at 100x100 text center middle "yes"]]
     ]
    ]
]
GiuseppeChillemi
@GiuseppeChillemi
Find returns the series at the position of search item, while select returns the ELEMENT after the search item. Is there an istruction to return the POSITION of the ELEMENT after the search item ?
if pos: find series value [pos: next pos]
Something like the code above
nedzadarek
@nedzadarek
@GiuseppeChillemi /tail?
GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek Thanks ! I have not seen it. Tail confuse me with /reverse
nedzadarek
@nedzadarek
find [1 2 3] 2
; == [2 3]
find/tail [1 2 3] 2
; == [3]
well, you can read description (? find)
GiuseppeChillemi
@GiuseppeChillemi
Rearding...
nedzadarek
@nedzadarek
@9214 face's parentand layout/only... I have never thought about it. Thank you.
GiuseppeChillemi
@GiuseppeChillemi

Which is the meaning of maintaining CR in blocks ?

Example:

 a: [aaa
        [ccccc]]

>> append a [bbbb [ccccc]]
== [aaa 
    [ccccc] bbbb [ccccc]]

Are:

[aaa 
    [ccccc] bbbb [ccccc]]

and

[aaa [ccccc] bbbb [ccccc]

The same ?

(Note, for readibility reasons I prefer the former bit I don't know how to add from code in this way)
nedzadarek
@nedzadarek

@GiuseppeChillemi they are the same (unless I don't know something):

a: [a
    b]
;== [a 
 ;   b
;]
aa: [a b]
; == [a b]
a = aa 
; == true

if you want to add newline (I guess that what you mean by CR) then you can just add newline in your code (hit enter):

a: [a]
; == [a]
append a [
    b]
;== [a 
;    b
;]

However certain operations may delete newlines. You can check and set/clear newlines manually using new-line/new-line?:


  arr: [a b c]
; [a b c]
  arr: next arr
; [b c]
  new-line? arr
; false
  new-line arr on ; on = true
; [
;    b c
; ]
  new-line? arr
; true
  head arr
; [a 
;     b c
; ]
GiuseppeChillemi
@GiuseppeChillemi
@nedzadarek so they are totally neutral ? No find/select , etc ?
nedzadarek
@nedzadarek

@GiuseppeChillemi

neutral

Yes, I haven't find any difference.

no find/select

what you mean?

GiuseppeChillemi
@GiuseppeChillemi
Something like Find series newline
nedzadarek
@nedzadarek
@GiuseppeChillemi you can use forall loop:
>> arr: head arr
== [a 
    b c
]
>> forall arr [
[    probe arr
[    print new-line? arr
[    ]
[a 
    b c
]
false
[
    b c
]
true
[c]
false
GiuseppeChillemi
@GiuseppeChillemi
So, forall detects newline and Find and Select do not.
Detects = manage.
While It is trasparent/invisible to Find/select
nedzadarek
@nedzadarek
@GiuseppeChillemi forall doesn't detects anything. It's just a loop that changes position of the series (arr: [1 2 3] > [1 2 3] > [2 3] > ...). new-line? detects new lines.
GiuseppeChillemi
@GiuseppeChillemi
I use the wrong terminology : It does not skip newline
While find/select do skip It.
I am on mobile client for gitter and can't test but Will try "foreach" and lenght? Too.
nedzadarek
@nedzadarek
@GiuseppeChillemi I don't think find/select skip new-line markers on purpose. It's just they are made to do something else. They are made to check values not new-line markers. New-line markers are not "normal values".
foreach won't work because it gives you element of the series. The element doesn't hold information about new-line markers.
GiuseppeChillemi
@GiuseppeChillemi
If lenght? counts new-lines too, I Need to reconsider some routines
nedzadarek
@nedzadarek
@GiuseppeChillemi no, length? doesn't count new lines markers. length? arr; 3
Toomas Vooglaid
@toomasv
@GiuseppeChillemi See also red-by-example
Vladimir Vasilyev
@9214
This markers exist solely for formatting purposes, and do not affect anything except series appearance.
Chris Prinos
@cprinos

how would you store functions in a block/series and then execute them with foreach. I tried various things along the lines of this:

a: function [x] [x + 1]
b: function [x] [x * 2]
c: function [x] [x * x]

funcs: [:a :b :c]

foreach f funcs [ print f 5]

which is printing 'a b c', when I'm trying to get '6 10 25'.

Vladimir Vasilyev
@9214
foreach f reduce funcs ...
Vladimir Vasilyev
@9214
@cprinos you're not storing functions, you're storing get-word!s.
Toomas Vooglaid
@toomasv
@cprinos To store functions: funcs: reduce [:a :b :c].
Palaing
@Palaing

Looking for a way to give a variable as an argument to cd? I try:

dir: %/D/Dropbox/utils
cd :dir

...that does not work: "cd does not allow get-word! for its :dir argument"
Any hint?

Boleslav Březovský
@rebolek
@Palaing use change-dir instead
cd is meant for interactive console sessions
nedzadarek
@nedzadarek

@cprinos to add to previous answers, you can as well add functions to the block funcs: append funcs :a.
ps. you may use a map! (key-value container, e.g. m: #(a: 42) m/a ; 42).

m: #()
m/a: function [x] [x + 1]
m/b: function [x] [x + 2]
m/c: function [x] [x + 3]

You can run functions by a name: m/a 1; == 2 or you can get keys (words) of the map and use foreach:

foreach key words-of m [probe m/:key 10]
; 11
; 12
; 13
Toomas Vooglaid
@toomasv
For maps keys-of is suggested.
Chris Prinos
@cprinos
@9214, @toomasv @nedzadarek thanks for the variations... will take a bit to convert my python thoughts to red thoughts
nedzadarek
@nedzadarek
@toomasv is there a reason for this? They are the same. I guess it can change in the future.
ps. I wanted to use keys-of but I forgot to add m before foreach's block. It showed me an error reserved for future use (or not yet implemented) so I just blindly took 2nd similar-looking function.
Toomas Vooglaid
@toomasv
@nedzadarek IIRC @dockimbel strongly adviced to use keys-of for maps, although currently there is no difference in practice.
nedzadarek
@nedzadarek
reflect: make action! [[
    {Returns internal details about a value via reflection} 
    value [any-type!] 
    field [word!] {spec, body, words, etc. **Each datatype defines its own reflectors**}
]]

Can I get list of datatype - reflector(s) from within red?

@toomasv I see, I will keep this in mind.

Toomas Vooglaid
@toomasv
Do you mean something like
>> ? "-of"
     body-of         function!     Returns the body of a value that supports reflection.
     caret-to-offset function!     Given a text position, returns the corresponding coordinate relative to the top-left o...
     class-of        function!     Returns the class ID of an object.
     keys-of         function!     Returns the list of words of a value that supports reflection.
     layout          function!     Return a face with a pane built from a VID description.
     spec-of         function!     Returns the spec of a value that supports reflection.
     values-of       function!     Returns the list of values of a value that supports reflection.
     words-of        function!     Returns the list of words of a value that supports reflection.
Better
>> ? "reflection"
     body-of         function!     Returns the body of a value that supports reflection.
     keys-of         function!     Returns the list of words of a value that supports reflection.
     reflect         action!       Returns internal details about a value via reflection.
     spec-of         function!     Returns the spec of a value that supports reflection.
     values-of       function!     Returns the list of values of a value that supports reflection.
     words-of        function!     Returns the list of words of a value that supports reflection.
nedzadarek
@nedzadarek
@toomasv I mean I want list like:
  • function - spec, body
  • map - words, values
    ...
Vladimir Vasilyev
@9214
system/catalog
Toomas Vooglaid
@toomasv
@nedzadarek These are those I know of, which may be strongly limited:
function - spec, body
map - keys (words), values, body
object - words (keys), values, body
nedzadarek
@nedzadarek
@toomasv I see, thank you.
@9214
SYSTEM/CATALOG is an object! with the following words and values:
     datatypes  none!         none
     actions    none!         none
     natives    none!         none
     accessors  block!        length: 12  [date! [date year month day zone ti...
     errors     object!       [throw note syntax script math access reserved1...
there is no such informations here.
Rudolf Meijer
@meijeru
system/catalog/accessors exists, but it contains only the words that can access components of values of direct types: extract system/catalog/accessors 2 => date! email! event! image! pair! time!. To complete Toomas's list:
object!, error!, port! and map! have words-of = keys-of, values-of and body-of
any-function! have spec-of, body-of and words-of(this one not yet implemented)