[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

What's a quick way to do this, /g/? Pic should be self-explanatory,

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 15
Thread images: 2

File: textjoin.png (4KB, 336x363px) Image search: [Google]
textjoin.png
4KB, 336x363px
What's a quick way to do this, /g/?

Pic should be self-explanatory, but I essentially want to combine Text 1 and 2, with line 1 of Text 1 being followed by line 1 of Text 2, then line 2 of Text 1 followed line 2 of Text 2, etc.... in the resulting text

It'd also be nice if it could add an additional empty line like the Result Text in the picture for each pair of lines from Text 1 and 2, but not a necessity
>>
>>58616608
Prelude> zip ["aaaa", "bbbb"] ["cccc", "dddd"]
[("aaaa","cccc"),("bbbb","dddd")]
>>
>>58616608
fizz buzz?
>>
>>58616608
what are you doing one of those take home interviews?
>>
>>58616608
#!/bin/bash
IFS=$'\n'
ar1=($text1)
ar2=($text2)
printf '%s\n' "$ar1" "$ar2" "${ar1[1]}" "${ar2[1]}"
>>
>>58616608
If you want that empty line
#!/bin/bash
IFS=$'\n'
ar1=($text1)
ar2=($text2)
printf '%s\n' "$ar1" "$ar2" '' "${ar1[1]}" "${ar2[1]}"
>>
>>58616892
>>58616845
>printf in bash
>>
>>58616608
text 1 on tape #1
text 2 on tape #2
begin
read tape #1
put tape #3
read tape tape #2
put tape #3
if not tape end goto begin
>>
>>58616926
Yes, so? How would you do that in echo, print every arguments in multiple lines? You'd have to make multiple calls to echo, or make a helper function.
echolines() {
for a; do
echo "$a"
done
}

Using printf this way is way cleaner. Plus, it's got some neat features, like quoting and displaying dates. It's even more portable, the -e/-n situation in echo is a portability mess. Speaking of echo, you can't use "--" in it, so there's no way to prevent user input from disappearing when they specify either one of -e, -n, -en, or -ne. This does not happen in printf.
>>
'\n\n'.join('\n'.join(pair) for pair in zip('AAAA\nBBBB'.split(), 'CCCC\nDDDD'.split()))
>>
>>58617011
Could you mail me your punch card?
>>
>>58616608

In Ruby:

def zip_it(t1, t2)
t1.split.zip(t2.split).map{|i| i.join("\n") + "\n\n"}
end

puts zip_it("AAAA\nBBBB", "CCCC\nDDDD")
>>
>>58617449
Sorry it's licensed under a non-free license.

However if you're willing to sign my End User License Agreement I could mail it to you
>>
File: Screenshot 2017-01-23 10.04.13.png (90KB, 788x1006px) Image search: [Google]
Screenshot 2017-01-23 10.04.13.png
90KB, 788x1006px
paste -d'\n' text1 text2
>>
>>58616608
Use COBOL
Thread posts: 15
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.