Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
Whatever.
GiuseppeChillemi
@GiuseppeChillemi
I have one veicle which has a GPS location device and a cloud service connected to it. The provider gave my a REST API key to communicate with its service. Could I use RED for this purpose ? Is there a tool or sample code and which scripts are needed ?
Vladimir Vasilyev
@9214
@GiuseppeChillemi you need to make HTTP requests with write/info and utilize API of this service.
Boleslav Březovský
@rebolek
Vladimir Vasilyev
@9214
Also see here.
GiuseppeChillemi
@GiuseppeChillemi
Could a function refinement have multiple and different words for each /refinement ?
Vladimir Vasilyev
@9214
@GiuseppeChillemi not sure what you mean by that. You can specify as many arguments as you need.
nedzadarek
@nedzadarek
@GiuseppeChillemi if you mean aliasing (e.g. foo/a is the same as foo/b) then no. You can however set words when you call one refinement, something like this:
f: function [/a a-var1 /b b-var1] [
  if a [b: a b-var1: a-var1] 
  if b [a: b a-var1: b-var1]  

  reduce [a a-var1 b b-var1] 
]

f
; == [false none false none]
f/a 1
; == [true 1 true 1]
f/b 1
; == [true 1 true 1]
Vladimir Vasilyev
@9214

if you mean aliasing (e.g. foo/a is the same as foo/b) then no

Ultimately this depends on how you implement a function.

GiuseppeChillemi
@GiuseppeChillemi

I mean:

f: function [/a a-var1 /b b-var1 b-var2]

Where b-var-2 is the second argument of /B

Vladimir Vasilyev
@9214
@GiuseppeChillemi have you actually tried to implement such function with multiple refinement arguments?
GiuseppeChillemi
@GiuseppeChillemi
Never
Just asking as I have not RED here
Vladimir Vasilyev
@9214
foo: func [x /a argument /b another one and many others][
    print [
        argument
        another one and many others
    ]
]
>> foo/a/b 'first 'second 'third 'fourth 'et 'cetera '.
second third fourth et cetera .
As you can see, sometimes you can answer your question yourself. :wink:
GiuseppeChillemi
@GiuseppeChillemi
Are you sure they belongs to /b ? They could be unrelated and general arguments like X because the example could work even if RED works the other way ;-)
@9214
Vladimir Vasilyev
@9214
@GiuseppeChillemi if you call a function with refinement, then you must to supply all of its arguments. And function spec requires all arguments to have unique names.

if you call a function with refinement, then you must to supply all of its arguments.

There exists an exception for this, though, it should remain unknown, to encourage best coding practices.

nedzadarek
@nedzadarek

@9214

Ultimately this depends on how you implement a function.

Do you mean a function creators that makes values of type function! (e.g. does, has, function etc)?

There exists an exception for this, though, it should remain unknown, to encourage best coding practices.

Just post it with a warning like DO NOT USE IT or something like this.

@GiuseppeChillemi I overdid with my answer. Sorry.

Vladimir Vasilyev
@9214
>> foo: func [/a x /b y][if any [a b][sort reduce [x y]]]
== func [/a x /b y][if any [a b] [sort reduce [x y]]]
>> foo/a 'arg
== [none arg]
>> foo/b 'arg
== [none arg]
>> foo
== none
GiuseppeChillemi
@GiuseppeChillemi
Tomorrow I'll try without /b and giving one less argument when calling the function.
Vladimir Vasilyev
@9214
Contrary to your comment, foo/a and foo/b are "the same".
GiuseppeChillemi
@GiuseppeChillemi
@rebolek I Need to extract columns and aliases from SQL queries. Do you know if such code has already been implemented ? I have found something in sql-protocol.r but has no aliases management.
nedzadarek
@nedzadarek

Contrary to your comment, foo/a and foo/b are "the same".

Could you elaborate?

Vladimir Vasilyev
@9214

@nedzadarek on what? foo called with two different refinements returns identical results. Thereas you said:

if you mean aliasing (e.g. foo/a is the same as foo/b) then no.

Of course you could start arguing that since foo/a and foo/b are two different path! values they are not the same, but, as far as encapsulation and functions go, they are the same.
nedzadarek
@nedzadarek
@9214 Ah, I mean setting it in the function's spec, like this: f: func [/ref1 = /ref2 a b] [ print a print b], so whenever you call f/ref1 1 2 or f/ref2 1 2 the results are "the same".
Vladimir Vasilyev
@9214
Actually, even your original example contradicts your comment.
@nedzadarek and that could be done with function constructor other than func or function.
nedzadarek
@nedzadarek
@9214 Yes, we can build our own function's constructor.
However build-in function creators (has, does etc) doesn't have that feature.
Boleslav Březovský
@rebolek
@GiuseppeChillemi I'm no expert on SQL, so I don't know what aliases are, sorry.
amreus
@amreus
cd code
Toomas Vooglaid
@toomasv
@GiuseppeChillemi Something like this quick hack?
name-char: charset [not ", "]
col-name: alias: [not ahead ["FROM"] keep [some name-char]]
column-rule: [col-name opt [opt " AS" space alias] [comma opt space | space ahead "FROM"]]
select-rule: ["SELECT " opt "DISTINCT " some column-rule]

;query: {SELECT a AS value, b.c AS sum FROM...}
;query: {SELECT a value, b.c AS sum FROM...}
;query: {SELECT a "value", b.c AS sum FROM...}
;query: {SELECT DISTINCT x "mycol" FROM...}
query: {SELECT DISTINCT xyz "from", a.xyz, zyx as klm FROM...}

parse query [collect [select-rule "FROM..."]]
Giuseppe Chillemi
@GiuseppeChillemi_gitlab
Didn't know about collect, I'll try it later.
@toomasv
hiiamboris
@hiiamboris
shouldn't split be able to accept a binary argument?
it's underlying parse mechanics seems to work OK with it
Rudolf Meijer
@meijeru
How should the binary argument be interpreted?
As a UTF-8 encoded string?
hiiamboris
@hiiamboris
no, simply as binary I think, so one can split binary data with binary delimiters
lepinekong
@lepinekong_twitter
@Palaing have fixed cd tree duplicates https://github.com/lepinekong/redlang.red/blob/86c828bcd576cc41fdcf6169184e0e02a196e303/cd.red#L5 unfortunately I cannot test remotely there is this nasty caching bug with red, I still have the old version :(
Johan Ingvast
@ingvast

I'm playing around with parse and coming from Rebol I miss the possibility to keep patterns in objects like

parse "123" [ any cc/num ]

where cc is an object with common parse rules and num being a charset.

But that does not seem to work in Red. Is there a reason for now allowing the syntax, or something on todo list?

Vladimir Vasilyev
@9214
@ingvast this and other Parse improvements are on todo list, but not of a high priority.
Johan Ingvast
@ingvast
Ok, thanks. Good to know.
Palaing
@Palaing
@lepinekong_twitter it works nicely for me :) (is there no way to empty the cache ?)
Boleslav Březovský
@rebolek
@lepinekong_twitter what caching bug?
ne1uno
@ne1uno
probably github wiki pages not appearing to be updated, so red doesn't request a new copy? seems like an easy thing to confirm by looking at their headers. (guessing they're fine)