>> foo: 'bar
== bar
>> 'foo = foo
== false
Except that word is not a float, it's a separate entity which can refer to other values, including floats.
You are right. However Red users prefers to use X!
as to say "it's a word containing datatype". We can use pi!: 42
but it breaks conventions.
'foo
looks different than foo
. I may be biased but foo
looks like variable in most language (or some variable-like thing in language that doesn't like mutations). 'foo
looks like some kind of symbol or something. So I would assume that you are comparing some value 'foo
with variable foo
.
>> foo: 'foo
== foo
>> 'foo = foo
== true
Because, following your "oh it looks like X so it should be X" logic, this:
(((,[:+/_2&{.)@](^:(2-~[)))&1 1)
is a, well, regex, I guess.
Because, following your "oh it looks like X so it should be X" logic, this:
(((,[:+/_2&{.)@](^:(2-~[)))&1 1)
is a, well, regex, I guess.
while in fact it's a Fibonacci sequence function.
Forth or some similar language?
integer!
with first [integer!]
then you have "eureka moment" - ah, it's different, I should test/ask about it. I learn faster that way.
sorry but red is supposed to be simple but as for type testing it's a headache compared to other languages.
I mean quirks in non-tech way. You see something that looks like, for example, datatype! but it is word!
@lepinekong_twitter @nedzadarek , it's not like other languages. You can't treat it as such in all cases. Sometimes, yes, because it does its best to help you and provide familiar affordances for your comfort. :^) Much of the time, things work as you might expect. You see words, but "get" values because they're evaluated. But you do have to be aware of when evaluation occurs at times. Simple appearances can be deceiving, but nobody has yet offered a better solution.
However Red users prefers to use X! as to say "it's a word containing datatype".
We try to gently encourage people to say words "refer to" values, but it's not always as comfortable as "X is 4" or "X is an integer".
but when you programmed in a few languages then some features are "obvious", like most languages have some kind of simple container, Ruby/C/... have arrays [1, 2, 3], Lisp has lists (1 2 3), Lua has tables {1 2 3}.
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?
Red works as intended and by design. It's not for everybody though. For those who feel it should work like other languages...there are other languages, and that's fine. But Red is not wrong. Red, bugs aside, can't be wrong. It is just Red. It may change and evolve, of course, but before suggesting changes we have to understand why it is the way it is.
@9214 of course it's subjective. We could have different background. I tried Rebol and Lua so I knew about "block magic" too. C user might get confused by some parts.
I have been thinking about change
ing value with parse
.
I have such code:
rule: ["bcd" keep ("dcb")]
parse bl: "abcd" [#"a" change collect set s [rule] (s/1)] bl
I want to "return" some value from the rule
and change original series (bl
in this case) with the value "returned" from the rule
.
What do you think about such code? Can it be done better?
@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.
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
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]
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
).
within?
does or just flavors of a = min a b
or all [a/x > b/x a/y > b/y]
any [a <= b a > b]
won't always hold true anymorea/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
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
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
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
]