reverse

Reverse scroll direction with 180 flipped scroll list

主宰稳场 提交于 2019-12-01 09:57:20
问题 I'm building a ionic / angular app and I'm in a situation that I would like to reverse the scroll direction on scroll input. Here jou can find a example of my situation: jsfiddle example In the example above I flipped the scroll list 180 degrees and flipped the divs inside the scroll list back 180 degree. I did this so that the messages are always starting at the bottom with no need of scrolling it down on page load etc. The downside is that also the scroll direction is flipped and this is

Scheme function to reverse a list

喜夏-厌秋 提交于 2019-12-01 09:48:52
问题 For my programming languages class I'm supposed to write a function in Scheme to reverse a list without using the pre-made reverse function. So far what I got was (define (reverseList lst) (COND ((NULL? lst) '()) (ELSE (CONS (reverseList(CDR lst)) (CAR lst))) )) The problem I'm having is that if I input a list, lets say (a b c) it gives me (((() . c) . b) . a) . How am I supposed to get a clean list without multiple sets of parenthesis and the . 's? 回答1: The problem with your implementation

Python 3 Writing Input file in reverse order to output file

血红的双手。 提交于 2019-12-01 08:50:15
I have tried searching, but I havent found exactly what I need. I am using python 3, and I need help writing a text file in reverse order to a different output file. So this would be the input file Hey, I am Fred Fred, what's up Fred fred fred And this would be the output file Fred fred fred Fred, what's up Hey, I am Fred If anyone has any insight into how to accomplish I would really appreciate it, with open (input_file_name) as fi, open(output_file_name, 'w') as fo: fo.writelines(reversed(fi.readlines())) If input_file is malformed (last line doesn't end with '\n') you may use a quick (maybe

Making an independent copy of a reversed array in JavaScript

浪子不回头ぞ 提交于 2019-12-01 08:14:17
问题 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

Reversing a string in Python using a loop? [duplicate]

烈酒焚心 提交于 2019-12-01 08:00:31
问题 This question already has answers here : Reverse a string in Python (26 answers) Closed 2 years ago . I'm stuck at an exercise where I need to reverse a random string in a function using only a loop (for loop or while?). I can not use ".join(reversed(string)) or string[::-1] methods here so it's a bit tricky. My code looks something like this: def reverse(text): while len(text) > 0: print text[(len(text)) - 1], del(text[(len(text)) - 1] I use the , to print out every single letter in text on

How to reverse a string that contains surrogate pairs

泪湿孤枕 提交于 2019-12-01 07:31:18
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 about how this code could be made more efficient or how there are one liners that I could use instead. I

Python 3 Writing Input file in reverse order to output file

99封情书 提交于 2019-12-01 06:53:51
问题 I have tried searching, but I havent found exactly what I need. I am using python 3, and I need help writing a text file in reverse order to a different output file. So this would be the input file Hey, I am Fred Fred, what's up Fred fred fred And this would be the output file Fred fred fred Fred, what's up Hey, I am Fred If anyone has any insight into how to accomplish I would really appreciate it, 回答1: with open (input_file_name) as fi, open(output_file_name, 'w') as fo: fo.writelines

Reverse a string with php

杀马特。学长 韩版系。学妹 提交于 2019-12-01 05:12:23
问题 I am trying to find a way to reverse a string, I've seen alternatives but i wanted to to it this way thinking outside the box and not using anyone else's code as an alternative, the code below reverses the string but I keep getting this error: Notice: Undefined offset: 25 in C:\wamp\www\test\index.php on line 15 25 being the length of the string which is being deincremented. //error_reporting(NULL); $string = trim("This is a reversed string"); //find length of string including whitespace $len

Using the google maps api for reverse geocoding lat/long from iPhone

六月ゝ 毕业季﹏ 提交于 2019-11-30 19:27:31
问题 I am currently using the google maps' reverse geocoding API to convert long/lat received from an iPhone's CoreLocation API into city/state information on a google app engine server. Would this be considered a violation of the terms? I've done some research and cannot find a direct answer to this question. Right now, we will be distributing our iPhone app for free. 回答1: According to Google's Terms of Service, you can only use the geocoder in conjunction with a Google Map. You may not: use or

Java, recursively reverse an array

[亡魂溺海] 提交于 2019-11-30 17:51:59
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 with this one, but, how to use the original recursively is beyond me at the moment. Any help is