Reverse words in a string: Difference between revisions

Added Easylang
(Added Easylang)
(8 intermediate revisions by 7 users not shown)
Line 656:
 
----------------------- Robert Frost</pre>
 
=={{header|BQN}}==
<syntaxhighlight lang="bqn">Split ← +`∘<⟜»⊸×⊸-⟜¬∘>⟜' '⊸⊔
Join ← (⊣∾' '∾⊢)´⍟(1<≡)
 
text ← ⍉≍⟨
"---------- Ice and Fire ------------"
""
"fire, in end will world the say Some"
"ice. in say Some "
"desire of tasted I've what From "
"fire. favor who those with hold I "
""
"... elided paragraph last ..."
""
"Frost Robert -----------------------"⟩
 
Join∘⌽∘Split¨ text</syntaxhighlight>
Alternative based on the approach described in [https://saltysylvi.github.io/blog/flat1.html this blog post]:
<syntaxhighlight lang="bqn">{(⍒+`∨⟜»' '=𝕩)⊏𝕩}¨ text</syntaxhighlight>
{{out}}
<pre>┌─
╵ "------------ Fire and Ice ----------"
⟨⟩
"Some say the world will end in fire,"
"Some say in ice."
"From what I've tasted of desire"
"I hold with those who favor fire."
⟨⟩
"... last paragraph elided ..."
⟨⟩
"----------------------- Robert Frost"
┘</pre>
 
=={{header|Bracmat}}==
Line 1,099 ⟶ 1,132:
end.</syntaxhighlight>
The output is the same as the Pascal entry.
 
=={{header|EasyLang}}==
<syntaxhighlight>
repeat
s$ = input
until error = 1
s$[] = strsplit s$ " "
for i = len s$[] downto 1
write s$[i] & " "
.
print ""
.
input_data
--------- Ice and Fire ------------
fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I
... elided paragraph last ...
Frost Robert -----------------------
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 1,135 ⟶ 1,192:
 
=={{header|Elena}}==
ELENA 56.0x:
<syntaxhighlight lang="elena">import extensions;
import system'routines;
Line 1,152 ⟶ 1,209:
"Frost Robert -----------------------"};
text.forEach::(line)
{
line.splitBy:(" ").sequenceReverse().forEach::(word)
{
console.print(word," ")
Line 1,714 ⟶ 1,771:
->
</pre>
 
=={{header|Insitux}}==
<syntaxhighlight lang="insitux">(var poem
"---------- Ice and Fire ------------
fire, in end will world the say Some
ice. in say Some
desire of tasted I've what From
fire. favor who those with hold I
... elided paragraph last ...
Frost Robert -----------------------")
 
(function split-join by then x
(-> x (split by) then (join by)))
 
(split-join "\n" (map @(split-join " " reverse)) poem)</syntaxhighlight>
 
=={{header|J}}==
Line 3,451 ⟶ 3,526:
----------------------- Robert Frost
</syntaxhighlight>
 
=={{header|RPL}}==
« { }
'''WHILE''' OVER " " POS '''REPEAT'''
LASTARG → sep
« OVER 1 sep SUB +
SWAP sep 1 + OVER SIZE SUB SWAP
»
'''END'''
SWAP + REVLIST
'''IFERR''' ∑LIST '''THEN''' 1 GET '''END'''
» '<span style="color:blue">REVWORDS</span>' STO
{ "---------- Ice and Fire ------------" "" "fire, in end will world the say Some" "ice. in say Some" "desire of tasted I've what From" "fire. favor who those with hold I" "" "... elided paragraph last ..." "" "Frost Robert -----------------------" }
1 « <span style="color:blue">REVWORDS</span> » DOLIST
 
{{out}}
<pre>
1: { "------------ Fire and Ice ----------"
""
"Some say the world will end in fire,"
"Some say in ice."
"From what I've tasted of desire"
"I hold with those who favor fire."
""
"... last paragraph elided ..."
""
"----------------------- Robert Frost" }
</pre>
 
=={{header|Ruby}}==
Line 4,049 ⟶ 4,153:
</pre>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">fn main() {
mut n := [
"---------- Ice and Fire ------------",
Line 4,115 ⟶ 4,219:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var lines = [
"---------- Ice and Fire ------------",
" ",
2,056

edits