Anonymous user
Compare length of two strings: Difference between revisions
no edit summary
No edit summary |
|||
Line 36:
"short" has length: 5 bytes.
</pre>
</lang>▼
{{output}}
<pre></pre>▼
=={{header|FreeBASIC}}==
Line 142 ⟶ 149:
"abcdef" has length 6 and is neither the longest nor the shortest string
"abcd" has length 4 and is the shortest string</pre>
▲=={{header|jq}}==
▲{{works with|jq}}
'''Works with gojq, the Go implementation of jq'''▼
▲<lang jq>
def s1: "longer";▼
def s2: "shorter😀";▼
[s1,s2]▼
| sort_by(length)▼
| reverse[]▼
| "\"\(.)\" has length (codepoints) \(length) and utf8 byte length \(utf8bytelength)."▼
▲</lang>
{{out}}▼
<pre>▼
"shorter😀" has length (codepoints) 8 and utf8 byte length 11.▼
"longer" has length (codepoints) 6 and utf8 byte length 6.▼
▲</pre>
=={{header|Julia}}==
Line 217 ⟶ 205:
length(codeunits("ñññ")) > length(codeunits("nnnn")) # true as well
</lang>
=={{header|jq}}==
{{works with|jq}}
▲'''Works with gojq, the Go implementation of jq'''
<lang jq>
▲def s1: "longer";
▲def s2: "shorter😀";
▲[s1,s2]
▲| sort_by(length)
▲| reverse[]
▲| "\"\(.)\" has length (codepoints) \(length) and utf8 byte length \(utf8bytelength)."
</lang>
▲{{out}}
▲<pre>
▲"shorter😀" has length (codepoints) 8 and utf8 byte length 11.
▲"longer" has length (codepoints) 6 and utf8 byte length 6.
</pre>
=={{header|Nim}}==
|