shuffle wrong this is better
Code:shuffle : pin_mode =!pin_mode if pin_mode then swap a,d swap b,c else swap b ,d swap c ,d endif
shuffle wrong this is better
Code:shuffle : pin_mode =!pin_mode if pin_mode then swap a,d swap b,c else swap b ,d swap c ,d endif
Last edited by richard; - 30th November 2014 at 12:26. Reason: pressed wrong button
Better? I'd say it's AWESOME! I had thought to suggest (as your original answer) using array values or various mask patterns perhaps, but - to my humble skills - there is simply no improvement possible to "swap". Somewhere, in the back of my mind, I remember seeing it, but had forgotten... I'll remember now!
That's awesome, however, I have one question. What is (=!)? Can you please translate to English what the line "pin_mode =!pin_mode" means. That's the only part I'm having a problem with right now. The good book references it at !=, but that is used when you have two expressions, not the same expression. The same expression will always be equal to itself.
Thanks,
Tony
! is the logical not operator afaik , anyway that's the way I use it (its a C thing but works in pbp too)
I think its the same as the "tilde" ~ but my laptop keyboard makes it hard to find. maybe someone can confirm this
pin_mode = ! (pin_mode) is the way to read it , if pin_mode is 1 then ! pin_mode becomes 0 or if pin_mode is 0 then ! pin_mode becomes 1
not to be confused with != which is not equal to
ps
just tried it . seems "~ ! not" are all the same thing (on bit and byte vars anyway) for what it worth
Last edited by richard; - 2nd December 2014 at 06:12. Reason: more
In binary, where there are two states, "NOT" or any variation thereof (~ ! etc) reverses the bit value, so... NOT 1 = 0. It makes sense on a bit level... if it's NOT a zero, it must be a one, yes? Now, of course if it is not, not a one, then it was all along a zero. In comedy, the "double negative" can lead to all sorts of Don Knott's style of humor - in computer science... not so much.
Bookmarks