code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
import Graphics.UI.Gtk
import Control.Monad
main = do
initGUI
window <- windowNew
set window [windowTitle:= "Graphical user input", containerBorderWidth:= 10]
vb <- vBoxNew False 0
containerAdd window vb
hb1 <- hBoxNew False 0
boxPackStart vb hb1 PackNatural 0
hb2 <- hBoxNew False 0
boxPackStart v... | 82User input/Graphical | 8haskell | 8xr0z |
import java.nio.charset.StandardCharsets;
import java.util.Formatter;
public class UTF8EncodeDecode {
public static byte[] utf8encode(int codepoint) {
return new String(new int[]{codepoint}, 0, 1).getBytes(StandardCharsets.UTF_8);
}
public static int utf8decode(byte[] bytes) {
return new ... | 79UTF-8 encode and decode | 9java | 938mu |
require 'fiddle'
c_var = Fiddle.dlopen(nil)['QueryPointer']
int = Fiddle::TYPE_INT
voidp = Fiddle::TYPE_VOIDP
sz_voidp = Fiddle::SIZEOF_VOIDP
Query = Fiddle::Closure::BlockCaller
.new(int, [voidp, voidp]) do |datap, lengthp|
message =
length = lengthp[0, sz_voidp].unpack('J').first
... | 75Use another language to call a function | 14ruby | rucgs |
null | 75Use another language to call a function | 15rust | 75lrc |
null | 74Van Eck sequence | 1lua | 0w1sd |
const
utf8encode=
n=>
(m=>
m<0x80
?Uint8Array.from(
[ m>>0&0x7f|0x00])
:m<0x800
?Uint8Array.from(
[ m>>6&0x1f|0xc0,m>>0&0x3f|0x80])
:m<0x10000
?Uint8Array.from(
[ m>>12&0x0f|0xe0,m>>6&0x3f|0x80,m>>0&0x3f|0x80])
:m<0x110000
... | 79UTF-8 encode and decode | 10javascript | ucfvb |
object Query {
def call(data: Array[Byte], length: Array[Int]): Boolean = {
val message = "Here am I"
val mb = message.getBytes("utf-8")
if (length(0) >= mb.length) {
length(0) = mb.length
System.arraycopy(mb, 0, data, 0, mb.length)
true
} else false
}
} | 75Use another language to call a function | 16scala | kruhk |
<?php
$urls = array(
'foo:
'urn:example:animal:ferret:nose',
'jdbc:mysql:
'ftp:
'http:
'ldap:
'mailto:John.Doe@example.com',
'news:comp.infosystems.www.servers.unix',
'tel:+1-816-555-1212',
'telnet:
'urn:oasis:names:specification:docbook:dtd:xml:4.1.2',
);
foreach ($urls AS... | 77URL parser | 12php | x17w5 |
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class Main
{
public static void main(String[] args) throws UnsupportedEncodingException
{
String normal = "http: | 78URL encoding | 9java | d8an9 |
def factor_pairs n
first = n / (10 ** (n.to_s.size / 2) - 1)
(first .. n ** 0.5).map { |i| [i, n / i] if n % i == 0 }.compact
end
def vampire_factors n
return [] if n.to_s.size.odd?
half = n.to_s.size / 2
factor_pairs(n).select do |a, b|
a.to_s.size == half && b.to_s.size == half &&
[a, b].count {|x|... | 70Vampire number | 14ruby | c6y9k |
package main
import (
"fmt"
"log"
"net/url"
)
func main() {
for _, escaped := range []string{
"http%3A%2F%2Ffoo%20bar%2F",
"google.com/search?q=%60Abdu%27l-Bah%C3%A1",
} {
u, err := url.QueryUnescape(escaped)
if err != nil {
log.Println(err)
continue
}
fmt.Println(u)
}
} | 80URL decoding | 0go | j4y7d |
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class UpdateConfig {
public static void main(String[] args) {
if (args[0] == null) {
System.out.println("filename required");
} else if (readConfig(args[0])) {
enableOption("seedsremoved");
... | 81Update a configuration file | 9java | krmhm |
var normal = 'http: | 78URL encoding | 10javascript | 6fs38 |
use std::cmp::{max, min};
static TENS: [u64; 20] = [
1,
10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000,
1000000000,
10000000000,
100000000000,
1000000000000,
10000000000000,
100000000000000,
1000000000000000,
10000000000000000,
1000000... | 70Vampire number | 15rust | lymcc |
import Stream._
import math._
import scala.collection.mutable.ListBuffer
object VampireNumbers extends App {
val elapsed: (=> Unit) => Long = f => {val s = System.currentTimeMillis; f; (System.currentTimeMillis - s)/1000}
val sexp = from(1, 2) | 70Vampire number | 16scala | uclv8 |
sub print_all {
foreach (@_) {
print "$_\n";
}
} | 67Variadic function | 2perl | i0no3 |
def check_isin(a):
if len(a) != 12 or not all(c.isalpha() for c in a[:2]) or not all(c.isalnum() for c in a[2:]):
return False
s = .join(str(int(c, 36)) for c in a)
return 0 == (sum(sum(divmod(2 * (ord(c) - 48), 10)) for c in s[-2::-2]) +
sum(ord(c) - 48 for c in s[::-2]))% 10
def... | 71Validate International Securities Identification Number | 3python | gvv4h |
assert URLDecoder.decode('http%3A%2F%2Ffoo%20bar%2F') == 'http: | 80URL decoding | 7groovy | 5lfuv |
import qualified Data.Char as Char
urlDecode :: String -> Maybe String
urlDecode [] = Just []
urlDecode ('%':xs) =
case xs of
(a:b:xss) ->
urlDecode xss
>>= return . ((Char.chr . read $ "0x" ++ [a,b]):)
_ -> Nothing
urlDecode ('+':xs) = urlDecode xs >>= return . (' ':)
urlDecode (x:xs) = urlDecod... | 80URL decoding | 8haskell | oqh8p |
null | 81Update a configuration file | 11kotlin | gvt4d |
import javax.swing.*;
public class GetInputSwing {
public static void main(String[] args) throws Exception {
int number = Integer.parseInt(
JOptionPane.showInputDialog ("Enter an Integer"));
String string = JOptionPane.showInputDialog ("Enter a String");
}
} | 82User input/Graphical | 9java | eb2a5 |
var str = prompt("Enter a string");
var value = 0;
while (value != 75000) {
value = parseInt( prompt("Enter the number 75000") );
} | 82User input/Graphical | 10javascript | 0wgsz |
null | 79UTF-8 encode and decode | 11kotlin | znwts |
import urllib.parse as up
url = up.urlparse('http:
print('url.scheme = ', url.scheme)
print('url.netloc = ', url.netloc)
print('url.hostname = ', url.hostname)
print('url.port = ', url.port)
print('url.path = ', url.path)
print('url.params = ', url.params)
print('url.query = ', url.query)
print('url.fragment = ', ur... | 77URL parser | 3python | lydcv |
null | 78URL encoding | 11kotlin | 0whsf |
use strict;
use warnings;
use feature 'say';
sub van_eck {
my($init,$max) = @_;
my(%v,$k);
my @V = my $i = $init;
for (1..$max) {
$k++;
my $t = $v{$i} ? $k - $v{$i} : 0;
$v{$i} = $k;
push @V, $i = $t;
}
@V;
}
for (
['A181391', 0],
['A171911', 1],
['... | 74Van Eck sequence | 2perl | ucyvr |
<?php
function printAll() {
foreach (func_get_args() as $x)
echo ;
$numargs = func_num_args();
for ($i = 0; $i < $numargs; $i++)
echo func_get_arg($i), ;
}
printAll(4, 3, 5, 6, 4, 3);
printAll(4, 3, 5);
printAll(, , , );
?> | 67Variadic function | 12php | r57ge |
package main
import (
"fmt"
"regexp"
)
var bits = []string{
"0 0 0 1 1 0 1 ",
"0 0 1 1 0 0 1 ",
"0 0 1 0 0 1 1 ",
"0 1 1 1 1 0 1 ",
"0 1 0 0 0 1 1 ",
"0 1 1 0 0 0 1 ",
"0 1 0 1 1 1 1 ",
"0 1 1 1 0 1 1 ",
"0 1 1 0 1 1 1 ",
"0 0 0 1 0 1 1 ",
}
var (
lhs = make(map[st... | 84UPC | 0go | lyqcw |
null | 82User input/Graphical | 11kotlin | kryh3 |
library(urltools)
urls <- c("foo://example.com:8042/over/there?name=ferret
"urn:example:animal:ferret:nose",
"jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true",
"ftp://ftp.is.co.za/rfc/rfc1808.txt",
"http://www.ietf.org/rfc/rfc2396.txt
"ldap://[2... | 77URL parser | 13r | yt86h |
x := 3 | 76Variables | 0go | krvhz |
import Foundation
func vampire<T>(n: T) -> [(T, T)] where T: BinaryInteger, T.Stride: SignedInteger {
let strN = String(n).sorted()
let fangLength = strN.count / 2
let start = T(pow(10, Double(fangLength - 1)))
let end = T(Double(n).squareRoot())
var fangs = [(T, T)]()
for i in start...end where n% i == ... | 70Vampire number | 17swift | 936mj |
sub vdc {
my @value = shift;
my $base = shift // 2;
use integer;
push @value, $value[-1] / $base while $value[-1] > 0;
my ($x, $sum) = (1, 0);
no integer;
$sum += ($_ % $base) / ($x *= $base) for @value;
return $sum;
}
for my $base ( 2 .. 5 ) {
print "base $base: ", join ' ', map { ... | 73Van der Corput sequence | 2perl | 0was4 |
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
public class Main
{
public static void main(String[] args) throws UnsupportedEncodingException
{
String encoded = "http%3A%2F%2Ffoo%20bar%2F";
String normal = URLDecoder.decode(encoded, "utf-8");
System.out.println... | 80URL decoding | 9java | wp5ej |
decodeURIComponent("http%3A%2F%2Ffoo%20bar%2F") | 80URL decoding | 10javascript | 8xj0l |
use warnings;
use strict;
my $needspeeling = 0;
my $seedsremoved = 1;
my $numberofstrawberries = 62000;
my $numberofbananas = 1024;
my $favouritefruit = 'bananas';
my @out;
sub config {
my (@config) = <DATA>;
push @config, "NUMBEROFSTRAWBERRIES $numberofstrawberries\n"
unle... | 81Update a configuration file | 2perl | n0kiw |
null | 79UTF-8 encode and decode | 1lua | 3dxzo |
foobar = 15
f x = x + foobar
where foobar = 15
f x = let foobar = 15
in x + foobar
f x = do
let foobar = 15
return $ x + foobar | 76Variables | 8haskell | n0eie |
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
public class UPC {
private static final int SEVEN = 7;
private static final Map<String, Integer> LEFT_DIGITS = Map.of(
" ... | 84UPC | 9java | 75frj |
require 'uri'
test_cases = [
,
,
,
,
,
,
,
,
,
,
,
,
,
]
class URI::Generic; alias_method :domain, :host; end
test_cases.each do |test_case|
puts test_case
uri = URI.parse(test_case)
%w[ scheme domain port path query fragment user password ].each do |attr|
puts if uri.send(att... | 77URL parser | 14ruby | v9t2n |
use url::Url;
fn print_fields(url: Url) -> () {
println!("scheme: {}", url.scheme());
println!("username: {}", url.username());
if let Some(password) = url.password() {
println!("password: {}", password);
}
if let Some(domain) = url.domain() {
println!("domain: {}", domain);
}... | 77URL parser | 15rust | uczvj |
def van_eck():
n, seen, val = 0, {}, 0
while True:
yield val
last = {val: n}
val = n - seen.get(val, n)
seen.update(last)
n += 1
if __name__ == '__main__':
print(, list(islice(van_eck(), 10)))
print(, list(islice(van_eck(), 1000))[-10:]) | 74Van Eck sequence | 3python | 5lmux |
def print_all(*things):
for x in things:
print x | 67Variadic function | 3python | n8diz |
package main
import "fmt"
type vector struct {
x, y, z float64
}
var (
a = vector{3, 4, 5}
b = vector{4, 3, 5}
c = vector{-5, -12, -13}
)
func dot(a, b vector) float64 {
return a.x*b.x + a.y*b.y + a.z*b.z
}
func cross(a, b vector) vector {
return vector{a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z,... | 72Vector products | 0go | 6fd3p |
RE = /\A[A-Z]{2}[A-Z0-9]{9}[0-9]{1}\z/
def valid_isin?(str)
return false unless str =~ RE
luhn(str.chars.map{|c| c.to_i(36)}.join)
end
p %w(US0378331005
US0373831005
U50378331005
US03378331005
AU0000XVGZA3
AU0000VXGZA3
FR0000988040).map{|tc| valid_isin?(tc) } | 71Validate International Securities Identification Number | 14ruby | 755ri |
null | 80URL decoding | 11kotlin | b7ckb |
<?php
$conf = file_get_contents('update-conf-file.txt');
$conf = preg_replace('/^(needspeeling)(|\s*\S*)$/mi', '; $1', $conf);
$conf = preg_replace('/^;?\s*(seedsremoved)/mi', '$1', $conf);
$conf = preg_replace('/^(numberofbananas)(|\s*\S*)$/mi', '$1 1024', $conf);
if (preg_match('/^;?\s*(numberofstrawberries)... | 81Update a configuration file | 12php | 753rp |
use strict;
use warnings;
use Unicode::UCD 'charinfo';
use utf8;
binmode STDOUT, ":encoding(UTF-8)";
my @chars = map {ord} qw/A /;
my $print_format = '%5s %-35s';
printf "$print_format%8s %s\n" , 'char', 'name', 'unicode', 'utf-8 encoding';
map{
my $name = charinfo($_)->{'na... | 79UTF-8 encode and decode | 2perl | b7lk4 |
import java.net.URI
object WebAddressParser extends App {
parseAddress("foo: | 77URL parser | 16scala | gvy4i |
function encodeChar(chr)
return string.format("%%%X",string.byte(chr))
end
function encodeString(str)
local output, t = string.gsub(str,"[^%w]",encodeChar)
return output
end | 78URL encoding | 1lua | 8xk0e |
printallargs1 <- function(...) list(...)
printallargs1(1:5, "abc", TRUE) | 67Variadic function | 13r | 0x8sg |
def pairwiseOperation = { x, y, Closure binaryOp ->
assert x && y && x.size() == y.size()
[x, y].transpose().collect(binaryOp)
}
def pwMult = pairwiseOperation.rcurry { it[0] * it[1] }
def dotProduct = { x, y ->
assert x && y && x.size() == y.size()
pwMult(x, y).sum()
} | 72Vector products | 7groovy | d80n3 |
extern crate luhn_cc;
use luhn_cc::compute_luhn;
fn main() {
assert_eq!(validate_isin("US0378331005"), true);
assert_eq!(validate_isin("US0373831005"), false);
assert_eq!(validate_isin("U50378331005"), false);
assert_eq!(validate_isin("US03378331005"), false);
assert_eq!(validate_isin("AU0000XVGZA... | 71Validate International Securities Identification Number | 15rust | j4472 |
val LEFT_DIGITS = mapOf(
" ## #" to 0,
" ## #" to 1,
" # ##" to 2,
" #### #" to 3,
" # ##" to 4,
" ## #" to 5,
" # ####" to 6,
" ### ##" to 7,
" ## ###" to 8,
" # ##" to 9
)
val RIGHT_DIGITS = LEFT_DIGITS.mapKeys {
it.key.replace(' ', 's').replace('#', ' ').replac... | 84UPC | 11kotlin | uc8vc |
package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
} | 83User input/Text | 0go | 93xmt |
int a;
double b;
AClassNameHere c; | 76Variables | 9java | qahxa |
[] unstack | 76Variables | 10javascript | isaol |
import Data.Monoid ((<>))
type Vector a = [a]
type Scalar a = a
a, b, c, d :: Vector Int
a = [3, 4, 5]
b = [4, 3, 5]
c = [-5, -12, -13]
d = [3, 4, 5, 6]
dot
:: (Num t)
=> Vector t -> Vector t -> Scalar t
dot u v
| length u == length v = sum $ zipWith (*) u v
| otherwise = error "Dotted Vectors must be of... | 72Vector products | 8haskell | j457g |
object Isin extends App {
val isins = Seq("US0378331005", "US0373831005", "U50378331005",
"US03378331005", "AU0000XVGZA3","AU0000VXGZA3", "FR0000988040")
private def ISINtest(isin: String): Boolean = {
val isin0 = isin.trim.toUpperCase
def luhnTestS(number: String): Boolean = {
def luhnTestN(di... | 71Validate International Securities Identification Number | 16scala | b77k6 |
def vdc(n, base=2):
vdc, denom = 0,1
while n:
denom *= base
n, remainder = divmod(n, base)
vdc += remainder / denom
return vdc | 73Van der Corput sequence | 3python | 8xe0o |
word = System.in.readLine()
num = System.in.readLine().toInteger() | 83User input/Text | 7groovy | znpt5 |
import System.IO (hFlush, stdout)
main = do
putStr "Enter a string: "
hFlush stdout
str <- getLine
putStr "Enter an integer: "
hFlush stdout
num <- readLn :: IO Int
putStrLn $ str ++ (show num) | 83User input/Text | 8haskell | b7yk2 |
van_eck = Enumerator.new do |y|
ar = [0]
loop do
y << (term = ar.last)
ar << (ar.count(term)==1? 0: ar.size - 1 - ar[0..-2].rindex(term))
end
end
ve = van_eck.take(1000)
p ve.first(10), ve.last(10) | 74Van Eck sequence | 14ruby | gvc4q |
function decodeChar(hex)
return string.char(tonumber(hex,16))
end
function decodeString(str)
local output, t = string.gsub(str,"%%(%x%x)",decodeChar)
return output
end | 80URL decoding | 1lua | pjlbw |
import re
import string
DISABLED_PREFIX = ';'
class Option(object):
def __init__(self, name, value=None, disabled=False,
disabled_prefix=DISABLED_PREFIX):
self.name = str(name)
self.value = value
self.disabled = bool(disabled)
self.disab... | 81Update a configuration file | 3python | d8bn1 |
null | 76Variables | 11kotlin | 1h4pd |
fn van_eck_sequence() -> impl std::iter::Iterator<Item = i32> {
let mut index = 0;
let mut last_term = 0;
let mut last_pos = std::collections::HashMap::new();
std::iter::from_fn(move || {
let result = last_term;
let mut next_term = 0;
if let Some(v) = last_pos.get_mut(&last_term)... | 74Van Eck sequence | 15rust | rulg5 |
object VanEck extends App {
def vanEck(n: Int): List[Int] = {
def vanEck(values: List[Int]): List[Int] =
if (values.size < n)
vanEck(math.max(0, values.indexOf(values.head, 1)) :: values)
else
values
vanEck(List(0)).reverse
}
val vanEck1000 = vanEck(1000)
println(s"The fi... | 74Van Eck sequence | 16scala | hguja |
use Wx;
package MyApp;
use base 'Wx::App';
use Wx qw(wxHORIZONTAL wxVERTICAL wxALL wxALIGN_CENTER);
use Wx::Event 'EVT_BUTTON';
our ($frame, $text_input, $integer_input);
sub OnInit
{$frame = new Wx::Frame
(undef, -1, 'Input window', [-1, -1], [250, 150]);
my $panel = new Wx::Panel($frame, -1);
$t... | 82User input/Graphical | 2perl | 3dazs |
from unicodedata import name
def unicode_code(ch):
return 'U+{:04x}'.format(ord(ch))
def utf8hex(ch):
return .join([hex(c)[2:] for c in ch.encode('utf8')]).upper()
if __name__ == :
print('{:<11} {:<36} {:<15} {:<15}'.format('Character', 'Name', 'Unicode', 'UTF-8 encoding (hex)'))
chars = ['A', '',... | 79UTF-8 encode and decode | 3python | pj2bm |
def print_all(*things)
puts things
end | 67Variadic function | 14ruby | fitdr |
null | 67Variadic function | 15rust | tnzfd |
public class VectorProds{
public static class Vector3D<T extends Number>{
private T a, b, c;
public Vector3D(T a, T b, T c){
this.a = a;
this.b = b;
this.c = c;
}
public double dot(Vector3D<?> vec){
return (a.doubleValue() * vec.a.dou... | 72Vector products | 9java | uc9vv |
def vdc(n, base=2)
str = n.to_s(base).reverse
str.to_i(base).quo(base ** str.length)
end
(2..5).each do |base|
puts + Array.new(10){|i| vdc(i,base)}.join()
end | 73Van der Corput sequence | 14ruby | isxoh |
use strict;
use warnings;
use feature 'say';
sub decode_UPC {
my($line) = @_;
my(%pattern_to_digit_1,%pattern_to_digit_2,@patterns1,@patterns2,@digits,$sum);
for my $p ('
push @patterns1, $p;
push @patterns2, $p =~ tr/
}
$pattern_to_digit_1{$patterns1[$_]} = $_ for 0..$
$pa... | 84UPC | 2perl | 8x40w |
import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s... | 83User input/Text | 9java | gvd4m |
struct VanEckSequence: Sequence, IteratorProtocol {
private var index = 0
private var lastTerm = 0
private var lastPos = Dictionary<Int, Int>()
mutating func next() -> Int? {
let result = lastTerm
var nextTerm = 0
if let v = lastPos[lastTerm] {
nextTerm = index - v
... | 74Van Eck sequence | 17swift | 4295g |
def printAll(args: Any*) = args foreach println | 67Variadic function | 16scala | 6ty31 |
function dotProduct() {
var len = arguments[0] && arguments[0].length;
var argsLen = arguments.length;
var i, j = len;
var prod, sum = 0; | 72Vector products | 10javascript | 75urd |
null | 73Van der Corput sequence | 15rust | n0qi4 |
object VanDerCorput extends App {
def compute(n: Int, base: Int = 2) =
Iterator.from(0).
scanLeft(1)((a, _) => a * base).
map(b => (n - 1) / b -> b).
takeWhile(_._1 != 0).
foldLeft(0d)((a, b) => a + (b._1 % base).toDouble / b._2 / base)
val n = scala.io.S... | 73Van der Corput sequence | 16scala | ti8fb |
require 'stringio'
class ConfigFile
def self.file(filename)
fh = File.open(filename)
obj = self.new(fh)
obj.filename = filename
fh.close
obj
end
def self.data(string)
fh = StringIO.new(string)
obj = self.new(fh)
fh.close
obj
end
def initialize(filehandle)
@lin... | 81Update a configuration file | 14ruby | ti1f2 |
WScript.Echo("Enter a string");
var str = WScript.StdIn.ReadLine();
var val = 0;
while (val != 75000) {
WScript.Echo("Enter the integer 75000");
val = parseInt( WScript.StdIn.ReadLine() );
} | 83User input/Text | 10javascript | kr6hq |
character_arr = [,,,,]
for c in character_arr do
puts + c.encode()
puts utf-8
puts + c.each_byte.map { |n| '%02X ' % (n & 0xFF) }.join
puts
end | 79UTF-8 encode and decode | 14ruby | aku1s |
fn main() {
let chars = vec!('A', '', '', '', '');
chars.iter().for_each(|c| {
let mut encoded = vec![0; c.len_utf8()];
c.encode_utf8(&mut encoded);
let decoded = String::from_utf8(encoded.to_vec()).unwrap();
let encoded_string = encoded.iter().fold(String::new(), |acc, val| form... | 79UTF-8 encode and decode | 15rust | eb5aj |
sub urlencode {
my $s = shift;
$s =~ s/([^-A-Za-z0-9_.!~*'() ])/sprintf("%%%02X", ord($1))/eg;
$s =~ tr/ /+/;
return $s;
}
print urlencode('http://foo bar/')."\n"; | 78URL encoding | 2perl | 5lzu2 |
func printAll<T>(things: T...) { | 67Variadic function | 17swift | dofnh |
object UTF8EncodeAndDecode extends App {
val codePoints = Seq(0x0041, 0x00F6, 0x0416, 0x20AC, 0x1D11E)
def utf8Encode(codepoint: Int): Array[Byte] =
new String(Array[Int](codepoint), 0, 1).getBytes(StandardCharsets.UTF_8)
def utf8Decode(bytes: Array[Byte]): Int =
new String(bytes, StandardCharsets.UTF_... | 79UTF-8 encode and decode | 16scala | qarxw |
a = 1 | 76Variables | 1lua | akg1v |
func vanDerCorput(n: Int, base: Int, num: inout Int, denom: inout Int) {
var n = n, p = 0, q = 1
while n!= 0 {
p = p * base + (n% base)
q *= base
n /= base
}
num = p
denom = q
while p!= 0 {
n = p
p = q% p
q = n
}
num /= q
denom /= q
}
var num = 0
var denom = 0
for base in... | 73Van der Corput sequence | 17swift | oqw8k |
import itertools
import re
RE_BARCODE = re.compile(
r
r
r
r
r
r
r
)
LEFT_DIGITS = {
(0, 0, 0, 1, 1, 0, 1): 0,
(0, 0, 1, 1, 0, 0, 1): 1,
(0, 0, 1, 0, 0, 1, 1): 2,
(0, 1, 1, 1, 1, 0, 1): 3,
(0, 1, 0, 0, 0, 1, 1): 4,
(0, 1, 1, 0, 0, 0, 1): 5,
(0, 1, 0... | 84UPC | 3python | oqg81 |
null | 83User input/Text | 11kotlin | 2m0li |
<?php
$s = 'http:
$s = rawurlencode($s);
?> | 78URL encoding | 12php | oqb85 |
null | 72Vector products | 11kotlin | 93zmh |
import Tkinter,tkSimpleDialog
root = Tkinter.Tk()
root.withdraw()
number = tkSimpleDialog.askinteger(, )
string = tkSimpleDialog.askstring(, ) | 82User input/Graphical | 3python | 6fe3w |
import Foundation
func encode(_ scalar: UnicodeScalar) -> Data {
return Data(String(scalar).utf8)
}
func decode(_ data: Data) -> UnicodeScalar? {
guard let string = String(data: data, encoding: .utf8) else {
assertionFailure("Failed to convert data to a valid String")
return nil
}
assert(string.unicod... | 79UTF-8 encode and decode | 17swift | 1hvpt |
sub urldecode {
my $s = shift;
$s =~ tr/\+/ /;
$s =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/eg;
return $s;
}
print urldecode('http%3A%2F%2Ffoo+bar%2F')."\n"; | 80URL decoding | 2perl | 6fx36 |
library(gWidgets)
options(guiToolkit="RGtk2")
w <- gwindow("Enter a string and a number")
lyt <- glayout(cont=w)
lyt[1,1] <- "Enter a string"
lyt[1,2] <- gedit("", cont=lyt)
lyt[2,1] <- "Enter 75000"
lyt[2,2] <- gedit("", cont=lyt)
lyt[3,2] <- gbutton("validate", cont=lyt, handler=function(h,...) {
txt <- svalue(ly... | 82User input/Graphical | 13r | fobdc |
import urllib
s = 'http:
s = urllib.quote(s) | 78URL encoding | 3python | 4235k |
URLencode("http://foo bar/") | 78URL encoding | 13r | 2mdlg |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.