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
Greg T
@gltewalt
Ok, I have an idea in mind, but - how do I grow a string?
Gregg Irwin
@greggirwin
append or insert.
Greg T
@gltewalt
Once I reach the end of my buffer, insert the start value at head and set last to the start value - start the incrementing again
?
(traversing a series would allow for incrementing and decrementing without a need for + or -)
Gregg Irwin
@greggirwin

My cheat is to parse backwards. I reverse the series, parse and change as I go, and when I hit a slot that doesn't carry, I break out to the end. If I carry all the way, I grow by appending. The last thing I do is reverse the series again.

Not sure how you could do it without +/-.

Unless you mean for the rollover chars. Those are selected from a map in my case.
Greg T
@gltewalt
Well you just find the value of the last character in the block of ascii values and do next, if you're incrementing - replace your last value with that new value
Moving the pointer forward or backward and replacing the current value of your last character with that new value
Gregg Irwin
@greggirwin
Ah, I see what you mean. I misunderstood your buffer/range question then. You could certainly do that. Hmmmm. Then you can just create a new string of allowed chars to step, and pick/poke +/- 1 to incr/decr.
Dang. I may be late for dinner now. ;^)
Greg T
@gltewalt
Yep
Gregg Irwin
@greggirwin
Thanks for the idea!
Greg T
@gltewalt
That would make 'going forward' or 'going backward' essentially the same. Equal effort.
No?
(That's the rough idea in my brain)
Gregg Irwin
@greggirwin
Yes, and eliminate my step-back function. As I looked at my code, the magic range markers bothered me. Now I know why. ;^)
Gregg Irwin
@greggirwin
May still need them. Will require a bit of brain work.
Greg T
@gltewalt
I won't get to explore until tonight sometime
Gregg Irwin
@greggirwin
I think this will make a next/back option easier, and could be universal if you won't want friendly alpha-num stepping. But if you want friendly, we'll still need range markers (0Aa and 9Zz).
Greg T
@gltewalt
Just use this if you want alpha-num?
red>> al-num
== [48 49 50 51 52 53 54 55 56 57 65 66 67 68 69 70 
    71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 
    87 88 89 90 97 98 99 100 101 102 103 104 105 106 
    107 108 109 110 111 112 113 114 115 116 117 118 
    119 120 121 122
]
Gregg Irwin
@greggirwin
Yes, though I'm using a string instead. What I mean is that I want 0-9 to always roll in that range, same for A-Z and a-z.
Greg T
@gltewalt
Oh, ok
Vladimir Vasilyev
@9214
Here I want a word to point to c context, while saving a: 1 entry in a global one. Can't wrap my head around it :confused:
Red []

c: context [a: 2]
a: 1

bind 'a c
print a   ; want it to be 2
Gregg Irwin
@greggirwin
A word can only have one binding. Bind returns the bound word, but where would Red save the old binding? You would need to use context? and store the original binding yourself. You can also use in to get a word bound to a specific context.
>> c: context [a: 2]
== make object! [
    a: 2
]
>> a: 1
== 1
>> ac: context? 'a
== make object! [
    datatype!: datatype!
    unset!: unset!
    none!: none!
    logic!: logic!
    block!: block!
    paren!: paren!
    string!: string!
    file!: file!
>> set 'a bind 'a c
== a
>> print a
a
>> print get a
2
>> get in c 'a
== 2
Vladimir Vasilyev
@9214
Hm, turns out I still don't get it :D
Okay, every word has a binding.binding is kinda of a pointer to a specific context. context is a namespace with entrys, every entry is a word: value pair, simpy speaking. Is everything correct?
Vladimir Vasilyev
@9214
By changing binding of a word I change a pointer to a different context, there this word has some entry with associated value, is that so?
And, to clarify, for now I thought that binding could be changed with bind <word> <context>. Am I wrong?
Vladimir Vasilyev
@9214
Obviously I'm getting something wrong... and can't get what exactly :satisfied:
Vladimir Vasilyev
@9214
but this one works as I expect
Red []

c: context [a: 2]
a: 1

blk: [a]
bind blk c ; i.e. bind all words (`a` word) in a block to a context
print reduce blk ; 2
print a          ; 1
geekyi
@geekyi
@9214 in and bind does the same thing, only a difference in syntax I think
I had a question on SO, and a github issue.. Which is kinda hard to search right now since I'm on mobile..
Vladimir Vasilyev
@9214
@geekyi I thought in is an alternative for path synthax? in obj 'foo is the same as obj/foo to my believe.
it just returns a value
ah, no, it returns a word, my bad
geekyi
@geekyi
I thought similar.. Like "is a in b?"
Vladimir Vasilyev
@9214
a word with a pointer to a specific context from which it was... ehm... inned?
Red []

c: context [a: 2]
a: 1

probe context? in c 'a
geekyi
@geekyi
But turns out to be same as bind but positions reversed. So bind itself might not mean what you think..
Vladimir Vasilyev
@9214
:worried:
geekyi
@geekyi
@9214 that code says.. What is the value of 'a in the context c
Vladimir Vasilyev
@9214
but value is 2 and it returns a
geekyi
@geekyi
Wait.. Let me get on my pc to check..
Vladimir Vasilyev
@9214
and if I'll evaluate that a I'll get 2
just for sanity check print :in = :bind :smile:
geekyi
@geekyi

just for sanity check print :in = :bind :smile:

It's not the exact same thing

Red []

c: context [a: 2]
a: 1

probe context? bind 'a c
Vladimir Vasilyev
@9214
Okay, let me show my trail of thought:
  • We have two separate contexts, global and local.
  • In global context we have an entry a: 1, but in local we have a: 2.
  • By default a word is bounded to a global context, there it has associated entry a: 1, hence it's value is 1.
  • If I want to change a binding, I should use bind 'a local-context. Now, in this local context, a has associated entry a: 2, hence its value should be 2.
  • But at the same time there's still an a: 1 entry in a global context to which I can revert back with bind 'a global-context.
  • ???
They both returning the same context, I can see that
Red []

c: context [a: 2]
a: 1

print equal? (probe context? in c 'a) (probe context? bind 'a c)
But I don't think that in and bind are the same thing