reverse

Reverse a list in Scheme with foldl and foldr

浪子不回头ぞ 提交于 2019-12-20 01:34:43
问题 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

Linearlayout order is reversed on some devices

a 夏天 提交于 2019-12-19 23:21:09
问题 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? 回答1: 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

Linearlayout order is reversed on some devices

烈酒焚心 提交于 2019-12-19 23:19:33
问题 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? 回答1: 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

How to print several strings backwards in Java

我与影子孤独终老i 提交于 2019-12-19 09:58:22
问题 I am trying to take a file full of strings, read it, then print out a few things: The string The string backwards AND uppercase The string length There are a few more things, however I haven't even gotten to that point and do not want to ask anyone to write the code entirely for me. After messing around with it for a while, I have it almost completed (I believe, save for a few areas). The piece that is tripping me up is the backwards word. We are required to put our output neatly into columns

How to reverse a string that contains surrogate pairs

人走茶凉 提交于 2019-12-19 08:52:37
问题 I have written this method to reverse a string public string Reverse(string s) { if(string.IsNullOrEmpty(s)) return s; TextElementEnumerator enumerator = StringInfo.GetTextElementEnumerator(s); var elements = new List<char>(); while (enumerator.MoveNext()) { var cs = enumerator.GetTextElement().ToCharArray(); if (cs.Length > 1) { elements.AddRange(cs.Reverse()); } else { elements.AddRange(cs); } } elements.Reverse(); return string.Concat(elements); } Now, I don't want to start a discussion

Java, recursively reverse an array

て烟熏妆下的殇ゞ 提交于 2019-12-18 19:06:07
问题 I haven't found anything with the specific needs of my function to do this, yes, it is for homework. So I have: public void reverseArray(int[] x) { } Precondition: x.length > 0 The fact that I can't have the function return anything, and the only argument is an array is leaving me stumped. I've tried using loops along with the recursion, but everything I've tried seems to end up with infinite instances of the function being made. I've gotten an idea/suggestion to use another function along

Java, recursively reverse an array

岁酱吖の 提交于 2019-12-18 19:05:16
问题 I haven't found anything with the specific needs of my function to do this, yes, it is for homework. So I have: public void reverseArray(int[] x) { } Precondition: x.length > 0 The fact that I can't have the function return anything, and the only argument is an array is leaving me stumped. I've tried using loops along with the recursion, but everything I've tried seems to end up with infinite instances of the function being made. I've gotten an idea/suggestion to use another function along

Concat a video with itself, but in reverse, using ffmpeg

帅比萌擦擦* 提交于 2019-12-18 12:33:20
问题 I was able to reverse with: ffmpeg -i input.mp4 -vf reverse output_reversed.mp4 And I can concat with: ffmpeg -i input.mp4 -i input.mp4 -filter_complex "[0:0] [0:1] [1:0] [1:1] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4 But can I concat with a reverse version of the video, with a single command? What I am trying to achieve is a ping pong effect, where the video plays once, then plays backwards right after. Thanks! 回答1: Technically, you can do it using ffmpeg -i input.mp4

reversing z-index based from page render order

*爱你&永不变心* 提交于 2019-12-18 11:47:51
问题 Example Markup: <div class="wrapper"> <h2>Trigger</h2> <div>This is some content</div> </div> <div class="wrapper"> <h2>Trigger</h2> <div>This is some content</div> </div> <div class="wrapper"> <h2>Trigger</h2> <div>This is some content</div> </div> Example CSS: .wrapper {z-index: 1} .wrapper div {display: none; position: absolute;} Via javascript (jQuery) I'm attaching a click event to each h2 that will then switch the content div to display: block. The intent is that these are expandable

Python Reverse Find in String

淺唱寂寞╮ 提交于 2019-12-18 11:41:57
问题 I have a string and an arbitrary index into the string. I want find the first occurrence of a substring before the index. An example: I want to find the index of the 2nd I by using the index and str.rfind() s = "Hello, I am 12! I like plankton but I don't like Baseball." index = 34 #points to the 't' in 'but' index_of_2nd_I = s.rfind('I', index) #returns = 36 and not 16 Now I would expect rfind() to return the index of the 2nd I (16) but it returns 36. after looking it up in the docs I found