Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
2
Task/URL-decoding/Apex/url-decoding.apex
Normal file
2
Task/URL-decoding/Apex/url-decoding.apex
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
EncodingUtil.urlDecode('http%3A%2F%2Ffoo%20bar%2F', 'UTF-8');
|
||||
EncodingUtil.urlDecode('google.com/search?q=%60Abdu%27l-Bah%C3%A1', 'UTF-8');
|
||||
1
Task/URL-decoding/Lasso/url-decoding.lasso
Normal file
1
Task/URL-decoding/Lasso/url-decoding.lasso
Normal file
|
|
@ -0,0 +1 @@
|
|||
bytes('http%3A%2F%2Ffoo%20bar%2F') -> decodeurl
|
||||
2
Task/URL-decoding/LiveCode/url-decoding-1.livecode
Normal file
2
Task/URL-decoding/LiveCode/url-decoding-1.livecode
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
put urlDecode("http%3A%2F%2Ffoo%20bar%2F") & cr & \
|
||||
urlDecode("google.com/search?q=%60Abdu%27l-Bah%C3%A1")
|
||||
2
Task/URL-decoding/LiveCode/url-decoding-2.livecode
Normal file
2
Task/URL-decoding/LiveCode/url-decoding-2.livecode
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
http://foo bar/
|
||||
google.com/search?q=`Abdu'l-Bah√°
|
||||
3
Task/URL-decoding/Nim/url-decoding.nim
Normal file
3
Task/URL-decoding/Nim/url-decoding.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import cgi
|
||||
|
||||
echo decodeUrl("http%3A%2F%2Ffoo%20bar%2F")
|
||||
7
Task/URL-decoding/Sidef/url-decoding.sidef
Normal file
7
Task/URL-decoding/Sidef/url-decoding.sidef
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
func urldecode(str) {
|
||||
str.gsub!('+', ' ');
|
||||
str.gsub!(/\%([A-Fa-f0-9]{2})/, {|a| 'C'.pack(a.hex)});
|
||||
return str;
|
||||
}
|
||||
|
||||
say urldecode('http%3A%2F%2Ffoo+bar%2F'); # => "http://foo bar/"
|
||||
6
Task/URL-decoding/Swift/url-decoding.swift
Normal file
6
Task/URL-decoding/Swift/url-decoding.swift
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
let encoded = "http%3A%2F%2Ffoo%20bar%2F"
|
||||
if let normal = encoded.stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding) {
|
||||
println(normal)
|
||||
}
|
||||
27
Task/URL-decoding/jq/url-decoding-1.jq
Normal file
27
Task/URL-decoding/jq/url-decoding-1.jq
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# Emit . and stop as soon as "condition" is true.
|
||||
def until(condition; next):
|
||||
def u: if condition then . else (next|u) end;
|
||||
u;
|
||||
|
||||
def url_decode:
|
||||
# The helper function converts the input string written in the given
|
||||
# "base" to an integer
|
||||
def to_i(base):
|
||||
explode
|
||||
| reverse
|
||||
| map(if 65 <= . and . <= 90 then . + 32 else . end) # downcase
|
||||
| map(if . > 96 then . - 87 else . - 48 end) # "a" ~ 97 => 10 ~ 87
|
||||
| reduce .[] as $c
|
||||
# base: [power, ans]
|
||||
([1,0]; (.[0] * base) as $b | [$b, .[1] + (.[0] * $c)]) | .[1];
|
||||
|
||||
. as $in
|
||||
| length as $length
|
||||
| [0, ""] # i, answer
|
||||
| until ( .[0] >= $length;
|
||||
.[0] as $i
|
||||
| if $in[$i:$i+1] == "%"
|
||||
then [ $i + 3, .[1] + ([$in[$i+1:$i+3] | to_i(16)] | implode) ]
|
||||
else [ $i + 1, .[1] + $in[$i:$i+1] ]
|
||||
end)
|
||||
| .[1]; # answer
|
||||
1
Task/URL-decoding/jq/url-decoding-2.jq
Normal file
1
Task/URL-decoding/jq/url-decoding-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
"http%3A%2F%2Ffoo%20bar%2F" | url_decode
|
||||
1
Task/URL-decoding/jq/url-decoding-3.jq
Normal file
1
Task/URL-decoding/jq/url-decoding-3.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
"http://foo bar/"
|
||||
Loading…
Add table
Add a link
Reference in a new issue