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
Boleslav Březovský
@rebolek
@nedzadarek Lua's table is certainly not a simple container type like C's array.
nedzadarek
@nedzadarek

@greggirwin

And do you treat all those things equally, expecting them to work the same? Do you add and remove items in the same way? Can you add and remove items? Are there varying performance implications? Named access to values?

I don't treat them equally (in 100%) but I think most general purpose languages share some operations (or there is a way to do it). Ruby arr.push(5) #=> [1, 2, 3, 4, 5] Lua table.insert(arr, 5). Of course there are some some differences but in the end I have container with 1 more element.

...there are other languages, and that's fine.

There are always macros/pre-load, DSLs etc. This language is very customizable.

redredwine
@redredwine

I am trying to play with parse to extract some information from some log files, but cannot figure out how to .
Let's say I am trying to extract the transaction id, the description and the startTime and the endTime, how do I do that. the log file has the following data:-

tid=93129247. PROCESSA Authorization Verification Starting. startTime: 2016-06-03 11:27:42.434, "
tid=3129247. System B call begin. startTime: 2016-06-03 11:27:42.435, "
tid=129247. From System B :soapenv:Client.Failure authorization failure in method authorize. startTime: 2016-06-03 11:27:42.435, endTime: 2016-06-03 11:27:42.510, "
tid=9247. System C Authorization Failed. startTime: 2016-06-03 11:27:42.434, endTime: 2016-06-03 11:27:42.510, "

it would also be good to have a column to display the difference between the startTime and the endTime

Vladimir Vasilyev
@9214
@nedzadarek ?
probe get also 'x probe parse x: "abc" [
    collect [
        to change keep "bc" [2 3] to end
    ]
]
Vladimir Vasilyev
@9214
@redredwine
log: next {
tid=93129247. PROCESSA Authorization Verification Starting. startTime: 2016-06-03 11:27:42.434, "
tid=3129247. System B call begin. startTime: 2016-06-03 11:27:42.435, "
tid=129247. From System B :soapenv:Client.Failure authorization failure in method authorize. startTime: 2016-06-03 11:27:42.435, endTime: 2016-06-03 11:27:42.510, "
tid=9247. System C Authorization Failed. startTime: 2016-06-03 11:27:42.434, endTime: 2016-06-03 11:27:42.510, "
}

line: [
    "tid=" 
    keep to dot 2 skip
    keep to ". startTime:" thru ["startTime:" space]
    keep to comma 2 skip
    ["endTime:" space keep to comma | keep (none)]
    thru newline
]

data: parse log [collect some line]
Extracted raw data then can be trivially preprocessed whichever way you want (conversion of id to integers or starting/ending time to date! (you'll need first to replace space with / for that, then load, etc). Just take 4 elements at a time (they're all strings, except for non-existent endTime in some cases, which I substituted with none).
hiiamboris
@hiiamboris
what is the rationale behind pair comparison as y before x?
https://github.com/red/red/blob/master/runtime/datatypes/pair.reds#L308
where does it make sense to compare like this? sorting?
nedzadarek
@nedzadarek
@9214 thank you for the answer.
I know that I have to go to the pattern (e.g. to change...) and skip rest (e.g. to end) but what is better with you approach? I want to know + and -.
Vladimir Vasilyev
@9214
@nedzadarek + and - of what? It's the same approach as yours, just refactored.
nedzadarek
@nedzadarek
I see.
Gregg Irwin
@greggirwin
:point_up: April 9, 2018 3:30 AM Inherited from Rebol. Is there a good reason to change it?
Let me see if I have any notes on other reasons.
Gregg Irwin
@greggirwin
@hiiamboris, I can only find the Rebol note that says " This is preferred to support the y sorting used by various graphics algorithms." Would be good to have concrete examples for that.
hiiamboris
@hiiamboris
@greggirwin I was just curious
I find that most operations on pairs are either akin to what within? does or just flavors of a = min a b or all [a/x > b/x a/y > b/y]
which I don't think we can do (or can we?) with simple comparisons as this way any [a <= b a > b] won't always hold true anymore
current behavior on the other hand reminds me of scan line ordering, and if it can be relied upon (can it?) I think some not so strict a/y < b/y tests can be replaced with a < b for conciseness, which is esp. handy if a or b is a function (less trouble with refinement handling as /y is a refinement in that case) or an immediate expression
Gregg Irwin
@greggirwin
Sorting has a lot of subtleties in Red, as sorting a block containing different types works, and you need to consider the inherent type priority.
Nenad Rakocevic
@dockimbel
@hiiamboris You can always use (pick a 'y) < (pick b 'y). Though, I agree with you that considering scan line ordering as the basis for comparisons for pair would be a good default option.
lepinekong
@lepinekong_twitter

What's the matter with use keyword : sometimes use exists

source use
use: func [locals [block!] body [block!]][do bind body make object! collect [
    forall locals [keep to set-word! locals/1] keep none
]]

but if you just run console it doesn't :worried:

 source use
*** Script Error: val needs a value
*** Where: set
*** Stack: source
ne1uno
@ne1uno
@lepinekong_twitter you must be running a script that defines it or includes another script that does?
nedzadarek
@nedzadarek

inherent type priority

Is there some reason why there is such priority?

sort/stable [1 2.2 "zzstring" #"_" <atag> #issue 229%]
; == ["zzstring" 1 2.2 #"_" #issue 229% <atag>]

It seems that string! is always before tag!, char! after integer!/float! (understandable). Why char! isn't before/after string? Some any-string! should stick together (I would add char! too)... well is there reason why there is such prority

lepinekong
@lepinekong_twitter
@ne1uno hmm it's not me but maybe I used a lib. will search thanks.
lepinekong
@lepinekong_twitter
@ne1uno you're right It was in altjson.red lib :+1:
@rgchris there is a bug for "use" keyword in altjson.red: probe test1 returns none because a is used at the beginning of comment.
a: 1
b: 2

use ["a b are some variables, weird test1 returns none whereas test2 returns 2"][
    test1: a
    test2: b
    probe test1
    probe test2
]
Vladimir Vasilyev
@9214
@lepinekong_twitter that's not a comment, because first block of use is not a function spec.
Vladimir Vasilyev
@9214
@rgchris :point_up: looks like you need to do additional sanity checks :wink:
ne1uno
@ne1uno
I think altjson in his scripts repo doesn't use use https://github.com/rgchris/Scripts/
ne1uno
@ne1uno
looks like a macro local to color-code, not used in altjson? not that it's not worth understanding how it was intended to work. just probably newer code as well
did rebol have a bigger problem leaking context? use seems like a solution in search of a problem in red
Vladimir Vasilyev
@9214
@ne1uno it's the user who leaks words into global context, not the language.
nedzadarek
@nedzadarek
How do I use function/extern in Red? In Rebol I could just do this: var1: 42 f: funct/extern [a] [var1: a] [var1]
Vladimir Vasilyev
@9214
@nedzadarek
>> x: 1
== 1
>> foo: function [a /extern x][x: x + a]
== func [a][x: x + a]
>> foo 10
== 11
>> x
== 11
nedzadarek
@nedzadarek
@9214 thank you.
Ah, it's like /local. ? is little misleading in case of function.
Vladimir Vasilyev
@9214
@nedzadarek it's not like /local, it's the exact opposite.
function does a deep-traversal and localizes all set-words it sees, /extern is a way to say which set-words should not be localized.
nedzadarek
@nedzadarek
@9214 I mean.. syntactically (?) - you use it in the spec like /local vars.
Vladimir Vasilyev
@9214
@nedzadarek it's called a refinement though. Both /local and /extern are refinements.
Except that you can't use /extern after function creation.
nedzadarek
@nedzadarek
Yes, /local and /extern are values of type refinement!. However when you use function!s you expect usage like this <name of function>/refinement1/refinement2 var1 var2 ref1-var1 ref2-var1.
Vladimir Vasilyev
@9214
And..?
nedzadarek
@nedzadarek
It's just little misleading. Never mind. btw. do you know other function that use pattern like (function functtion-name [var /ref ...] body?
Vladimir Vasilyev
@9214
Red have built-in function, func, does and has function constructors, if that's what you mean.
This spec format is a dialect, specific for everything that inherits make function! ...
nedzadarek
@nedzadarek
@9214 No, I mean functions that use refinement!. Not like this: foo/ref1/ref2 .... But like this: foo [var /ref1 something something-else /ref2 another-thing] some-var.
Vladimir Vasilyev
@9214
@nedzadarek have you read what I said about function spec dialect?
You can build function constructor yourself, and make it use the same format or a newly designed one (@rebolek has a couple of examples for that).
nedzadarek
@nedzadarek
@9214 Yes, I read it. It's (mini) dialect. I wonder if (and how) other people use that too.
I have seen that rebolek's work.
Boleslav Březovský
@rebolek
function constructors FTW!
Vladimir Vasilyev
@9214
@nedzadarek other people (including you) use it regularly whenever they create a new function with func or function.
nedzadarek
@nedzadarek
@9214 I mean... beside func or function.