concatenation

String.Concat inefficient code?

回眸只為那壹抹淺笑 提交于 2019-12-09 07:46:10
问题 I was investigating String.Concat : (Reflector) very strange : the have the values array , they creating a NEW ARRAY for which later they send him to ConcatArray . Question : Why they created a new array ? they had values from the first place... edit code : public static string Concat(params string[] values) { if (values == null) { throw new ArgumentNullException("values"); } int totalLength = 0; string[] strArray = new string[values.Length]; for (int i = 0; i < values.Length; i++) { string

F# - Breaking a List into Concatenated Strings by an Interval

青春壹個敷衍的年華 提交于 2019-12-09 04:33:26
I have a list of email addresses, and I need to send an email notification to each address. I'd like to do this in blocks of 25 addresses at a time. Is there any quick way in a functional language like F# to "fold" (concatenate) 25 emails addresses together... each separated by a semicolon. I know there is the String.Split method in .NET, but I need to concat 25 at a time. What is the most elegant way to perform this in F#? Here's a way to break into groups of at most N: // break a sequence up into a sequence of arrays, // each of length at most 'n' let Break n (s:seq<_>) = seq { use e = s

PBKDF2 Excel UDF and how to concatenate INT(i)

妖精的绣舞 提交于 2019-12-09 04:00:36
问题 Recently I have been digging into cryptography and getting hashing and encryption functions working in Excel which I might use in a project I am working on. I got simple hashing functions working using, for example: Function Hash(ByVal plainText As String) Dim utf8Encoding As Object Dim hashManager As Object Dim hashBytes() As Byte Set utf8Encoding = CreateObject("System.Text.UTF8Encoding") Set hashManager = CreateObject("System.Security.Cryptography.SHA512Managed") hashBytes = utf8Encoding

concatenation of two unicode srings?

丶灬走出姿态 提交于 2019-12-09 03:56:29
问题 #!/usr/bin/python # -*- coding: utf-8 -*- import re separators = [u"।", u",", u"."] dat=open(r"C:\Users\User\Desktop\text4.txt",'r').read() text=dat.decode("utf-8") wros=text.split() out="" import string space=" " counter=0; for word in wros: out=u" ".join(word) writ=open("C:\\Users\\User\\Desktop\\text5.txt",'w') writ.write(out.encode('utf-8')) writ.close() text4.txt contains भारत का इतिहास काफी समृद्ध एवं विस्तृत है। text5.txt outputs as ह ै । desired output is भारत का इतिहास काफी समृद्ध

Concatenating Matrices in R

爷,独闯天下 提交于 2019-12-09 02:25:16
问题 How can I concatenate matrices of same columns but different number of rows? For example, I want to concatenate a ( dim(a) = 15 7000 ) and b (dim(b) = 16 7000) and I want the result to be a matrix of 31 rows by 7000 columns. Can I do this for matrices of different rows and columns.? Say I want to combine a matrix of 15 rows and 7000 columns with another of 16 rows and 7500 columns. Can I create one dataset with that? 回答1: Sounds like you're looking for rbind : > a<-matrix(nrow=10,ncol=5) > b<

SQL Server : Group by string concatenation

喜你入骨 提交于 2019-12-09 01:26:35
问题 I have a question. I know that has been asked before. I looked through the related questions but I could not get my SQL script to work. Here is my query : SELECT T1.PART_ID, T2.ID, T2.DESCRIPTION FROM #TEMP T1 INNER JOIN #TEMP2 T2 ON T1.PART_ID = T2.PART_ID ORDER BY T2.ID Table: PART_ID | ID | DESCRIPTION ---------------------------------- 10002 | 1182505 | Tagfahrlichtschaltung 80029 | 1182505 | Bluetooth 20004 | 1212866 | Kindersitzbefestigung 10045 | 1212866 | Lederlenkradrriegelung 11908

R: Merge of rows in same data table, concatenating certain columns

感情迁移 提交于 2019-12-08 23:13:16
问题 I have my data table in R. I want to merge rows which have an identical customerID , and then concatenate the elements of other merged columns. I want to go from this: title author customerID 1 title1 author1 1 2 title2 author2 2 3 title3 author3 1 to this: title author Group.1 1 title1, title3 author1, author3 1 2 title2 author2 2 回答1: The aggregate function should help you in finding a solution: dat = data.frame(title = c("title1", "title2", "title3"), author = c("author1", "author2",

Cannot concatenate strtok's output variable. strcat and strtok

筅森魡賤 提交于 2019-12-08 21:18:33
I’ve spent hours on this program and have put several hours online searching for alternatives to my methods and have been plagued with crashes and errors all evening… I have a few things I'd like to achieve with this code. First I’ll explain my problems, then I’ll post the code and finally I’ll explain my need for the program. The program outputs just the single words and the concatenate function does nothing. This seems like it should be simple enough to fix... My first problem is that I cannot seem to get the concatenate function to work, I used the generic strcat function which didn't work

Coalesce vs empty string concatenation

这一生的挚爱 提交于 2019-12-08 19:07:27
问题 My coworker is new to C# and didn't know about the coalesce operator. So, I saw him write a line of code like this: string foo = "" + str; The idea being that if str is null, this expression would return an empty string. Of course, that could be rewritten as this: string foo = str ?? ""; And I feel that would be more readable. But is it really that big a deal? Are the readability benefits enough to suggest going back and making those lines look like the second? Or is this one of those things

String Pool: “Te”+“st” faster than “Test”?

只谈情不闲聊 提交于 2019-12-08 17:38:20
问题 I am trying some performance benchmark regarding String Pool. However, the outcome is not expected. I made 3 static methods perform0() method ... creates a new object every time perform1() method ... String literal "Test" perform2() method ... String constant expression "Te"+"st" My expectation was (1. fastest -> 3. slowest) "Test" because of string pooling "Te"+"st" because of string pooling but bit slower than 1 because of + operator new String(..) because of no string pooling. But the