reverse

Delphi Reverse order of bytes

孤街浪徒 提交于 2019-12-01 20:52:17
I have been trying to write a function that takes two pointers (an input and an output) and writes the bytes from the input into the output in reverse order. So far I have not been able to make it work correctly. procedure ReverseBytes(Source, Dest: Pointer; Size: Integer); var Index: Integer; begin Move(Pointer(LongInt(Source) + Index)^, Pointer(LongInt(Dest) + (Size - Index))^ , 1); end; Can anyone please suggest a better way of doing this. Thanks. procedure ReverseBytes(Source, Dest: Pointer; Size: Integer); var Index: Integer; begin for Index := 0 to Size - 1 do Move(Pointer(LongInt(Source

Reverse a list in Scheme with foldl and foldr

痴心易碎 提交于 2019-12-01 18:49:30
How can you define a function to reverse a list in Scheme by using foldr and foldl ? What we want is a succinct solution to reverse a list in Scheme using a foldl call and a different solution using a foldr call, as defined: (define (foldl operation lst initial) (if (null? lst) initial (foldl operation (cdr lst) (operation (car lst) initial)))) and (define (foldr operation lst initial) (if (null? lst) initial (operation (car lst) (foldr operation (cdr lst) initial)))) The astute person will observe that the foldl implementation is tail-recursive because the returned value is computed as each

Reverse string method

此生再无相见时 提交于 2019-12-01 18:39:00
I am trying to solve the following problem but how do write the method that accepts String as an argument? Write a method named printReverse that accepts a String as an argument and prints the characters in the opposite order. If the empty string is passed as an argument, the method should produce no output. Be sure to write a main method that convincingly demonstrates your program in action. Do not use the reverse method of the StringBuilder or StringBuffer class! So far I have solved it in a easier manner: import java.util.Scanner; class ReverseString { public static void main(String args[])

Linearlayout order is reversed on some devices

走远了吗. 提交于 2019-12-01 18:29:56
I have a LinearLayout and on some devices all the views are reversed. The Good Version: [b1] [b2] [b3] On some devices: [b3] [b2] [b1] Why does that happen and how can I fix it? If you're targeting and testing on API level >=17 (i.e. Android 4.2) this might be caused by RTL support, as described here . If you don't want this, you can either change android:layoutDirection for each particular view (and since the default is inherit , the root view should suffice) or you can disable it for the whole application by setting android:supportsRtl="false" in the AndroidManifest.xml file. Or, you could

How to reverse a sentence in R?

大兔子大兔子 提交于 2019-12-01 16:42:25
I want a function that takes a string (NOT a vector) and reverses the words in that string. For example, rev_sentence("hi i'm five") ## [1] "five i'm hi" I have a function that reverses individual characters, but not something that will reverse a string that's essentially a sentence. In R , We can use strsplit to split at one or more spaces and then reverse the elements and paste it together sapply(strsplit(str1, "\\s+"), function(x) paste(rev(x), collapse=" ")) #[1] "five i'm hi" If there is only a single string, then paste(rev(strsplit(str1, "\\s+")[[1]]), collapse= " ") #[1] "five i'm hi"

JFreeChart - how to reverse axis order

China☆狼群 提交于 2019-12-01 16:06:29
问题 I'm creating XYPlot and I need to reverse the order on y-Axis (that is, I need lower numbers to be higher on the axis). I would appreciate any hints how to do that. 回答1: I had the same problem as you. I found this: ChartPanel.getChart().getXYPlot().getRangeAxis().setInverted(boolean) 回答2: to reverse the Y-axis ... you can use ChartPanel.getChart().getXYPlot().getDomainAxis().setInverted(boolean) Source: Reverse X-axis numeric labels in JFreeChart 来源: https://stackoverflow.com/questions

Reverse a byte using assembly language

大城市里の小女人 提交于 2019-12-01 15:35:34
问题 I'm in a microprocessors class and we are using assembly language in Freescale CodeWarrior to program a 68HCS12 micro controller. Our assignment this week is to revers a byte, so if the byte was 00000001, the output would be 10000000, or 00101011 to 11010100. We have to use assembly language, and were told we could use rotates and shifts (but not limited to!) to accomplish this task. I'm really at a loss as to where I should start. 回答1: If you can spare the 256 bytes extra code size, a lookup

How to reverse an array using the Reverse method. C# [closed]

和自甴很熟 提交于 2019-12-01 13:11:05
For some reason when I apply the reverse method, nothing changes. public static string ReverseString(string word) { char[] myArray = word.ToCharArray(); myArray.Reverse(); string ans = string.Join("", myArray); return ans; } Try Array.Reverse(myArray) instead of myArray.Reverse() . You are confusing Enumerable.Reverse and Array.Reverse methods. IEnumerable<char>.Reverse : Returns a new reversed array without changing the old array myArray = myArray.Reverse(); Array.Reverse : A Void method that will reverse the input array Array.Reverse(myArray); Perhaps you're confusing the method you're using

how do i get “this = this” in prototype working

依然范特西╮ 提交于 2019-12-01 11:10:01
问题 Ok peep's so I know it's bad practice to mess with prototypes but here it is anyway... Array.prototype.rev= function(){ this.reverse(); } Works fine! Updates the source array variable, ary , as expected eg: ary = [123, 456]; ary.rev(); // result: ary == [456, 123] My problem comes when writing a similar property for String . What I would like to do is something like this... String.prototype.rev= function(){ this.split(''); this.reverse(); this.join(''); } Seems simple enough right! Split the

Making an independent copy of a reversed array in JavaScript

杀马特。学长 韩版系。学妹 提交于 2019-12-01 10:34:39
Here is my fiddle: http://jsfiddle.net/sepoto/Zgu9J/1/ I'm starting with a reverse function: function reverseArr(input) { var ret = new Array; for(var i = input.length-1; i >= 0; i--) { ret.push(input[i]); } //I tried changing the return value to //return ret.slice(0) which has no effect on making //an independent copy return ret; } The second array I make pointOrigins2 is not an independent copy of pointOrigins1. In other words modifying pointOrigins2 is also modifying pointOrigins1 which is not what I need to achieve. From my reading on StackOverflow I have tried a few options such as using