code stringlengths 1 46.1k ⌀ | label class label 1.18k
classes | domain_label class label 21
classes | index stringlengths 4 5 |
|---|---|---|---|
require("LuaXML")
function addNode(parent, nodeName, key, value, content)
local node = xml.new(nodeName)
table.insert(node, content)
parent:append(node)[key] = value
end
root = xml.new("CharacterRemarks")
addNode(root, "Character", "name", "April", "Bubbly: I'm > Tam and <= Emily")
addNode(root, "Characte... | 34XML/Output | 1lua | 1kbpo |
null | 35XML/Input | 11kotlin | 8qq0q |
isPrime :: Integer -> Bool
isPrime n
|n == 2 = True
|n == 1 = False
|otherwise = null $ filter (\i -> mod n i == 0 ) [2 .. root]
where
root :: Integer
root = toInteger $ floor $ sqrt $ fromIntegral n
isWieferichPrime :: Integer -> Bool
isWieferichPrime n = isPrime n && mod ( 2 ^ ( n - 1 ) - ... | 45Wieferich primes | 8haskell | w15ed |
import java.util.*;
public class WieferichPrimes {
public static void main(String[] args) {
final int limit = 5000;
System.out.printf("Wieferich primes less than%d:\n", limit);
for (Integer p : wieferichPrimes(limit))
System.out.println(p);
}
private static boolean[... | 45Wieferich primes | 9java | k79hm |
require
module Modulo
refine Integer do
def factorial_mod(m) = (1..self).inject(1){|prod, n| (prod *= n) % m }
end
end
using Modulo
primes = Prime.each(11000).to_a
(1..11).each do |n|
res = primes.select do |pr|
prpr = pr*pr
((n-1).factorial_mod(prpr) * (pr-n).factorial_mod(prpr) - (-1)**n) % (pr... | 43Wilson primes of order n | 14ruby | ab51s |
null | 43Wilson primes of order n | 15rust | ep4aj |
null | 37Write language name in 3D ASCII | 11kotlin | vcm21 |
io.write(" /$$\n")
io.write("| $$\n")
io.write("| $$ /$$ /$$ /$$$$$$\n")
io.write("| $$ | $$ | $$ |____ $$\n")
io.write("| $$ | $$ | $$ /$$$$$$$\n")
io.write("| $$ | $$ | $$ /$$__ $$\n")
io.write("| $$$$$$$$| $$$$$$/| $$$$$$$\n")
io.write("|________/ \______/ \_______/\n") | 37Write language name in 3D ASCII | 1lua | ul9vl |
from tkinter import *
import tkinter.messagebox
def maximise():
root.geometry(.format(root.winfo_screenwidth(), root.winfo_screenheight(), 0, 0))
def minimise():
root.iconify()
def delete():
if tkinter.messagebox.askokcancel(,):
root.quit()
root = Tk()
mx=Button(root,text=,command=maximise)
mx.grid()
mx... | 40Window management | 3python | 96dmf |
use feature 'say';
use ntheory qw(is_prime powmod);
say 'Wieferich primes less than 5000: ' . join ', ', grep { is_prime($_) and powmod(2, $_-1, $_*$_) == 1 } 1..5000; | 45Wieferich primes | 2perl | n8biw |
use strict;
use X11::Protocol;
my $X = X11::Protocol->new;
my $window = $X->new_rsrc;
$X->CreateWindow ($window,
$X->root,
'InputOutput',
0,
0,
0,0,
30... | 42Window creation/X11 | 2perl | 523u2 |
wheel =
middle, wheel_size = wheel[4], wheel.size
res = File.open().each_line.select do |word|
w = word.chomp
next unless w.size.between?(3, wheel_size)
next unless w.match?(middle)
wheel.each_char{|c| w.sub!(c, ) }
w.empty?
end
puts res | 38Word wheel | 14ruby | gul4q |
require 'lxp'
data = [[<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
<Pet Type="dog" Name="Rover" />
... | 35XML/Input | 1lua | oss8h |
size_t lr = 0;
size_t filterit(void *ptr, size_t size, size_t nmemb, void *stream)
{
if ( (lr + size*nmemb) > BUFSIZE ) return BUFSIZE;
memcpy(stream+lr, ptr, size*nmemb);
lr += size*nmemb;
return size*nmemb;
}
int main()
{
CURL *curlHandle;
char buffer[BUFSIZE];
regmatch_t amatch;
regex_t cregex;
... | 49Web scraping | 5c | yza6f |
def isPrime(n):
for i in range(2, int(n**0.5) + 1):
if n% i == 0:
return False
return True
def isWeiferich(p):
if not isPrime(p):
return False
q = 1
p2 = p ** 2
while p > 1:
q = (2 * q)% p2
p -= 1
if q == 1:
return True
else:
... | 45Wieferich primes | 3python | dopn1 |
from Xlib import X, display
class Window:
def __init__(self, display, msg):
self.display = display
self.msg = msg
self.screen = self.display.screen()
self.window = self.screen.root.create_window(
10, 10, 100, 100, 1,
self.screen.root_depth,
backg... | 42Window creation/X11 | 3python | 4v65k |
package main
import "fmt"
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
}
}
for i := l... | 47Weird numbers | 0go | 96qmt |
typedef struct word_count_tag {
const char* word;
size_t count;
} word_count;
int compare_word_count(const void* p1, const void* p2) {
const word_count* w1 = p1;
const word_count* w2 = p2;
if (w1->count > w2->count)
return -1;
if (w1->count < w2->count)
return 1;
return 0;
}... | 50Word frequency | 5c | vcs2o |
weirds :: [Int]
weirds = filter abundantNotSemiperfect [1 ..]
abundantNotSemiperfect :: Int -> Bool
abundantNotSemiperfect n =
let ds = descProperDivisors n
d = sum ds - n
in 0 < d && not (hasSum d ds)
hasSum :: Int -> [Int] -> Bool
hasSum _ [] = False
hasSum n (x:xs)
| n < x = hasSum n xs
| otherwise =... | 47Weird numbers | 8haskell | bjmk2 |
require
puts Prime.each(5000).select{|p| 2.pow(p-1 ,p*p) == 1 } | 45Wieferich primes | 14ruby | tnaf2 |
null | 45Wieferich primes | 15rust | zdeto |
func primeSieve(limit: Int) -> [Bool] {
guard limit > 0 else {
return []
}
var sieve = Array(repeating: true, count: limit)
sieve[0] = false
if limit > 1 {
sieve[1] = false
}
if limit > 4 {
for i in stride(from: 4, to: limit, by: 2) {
sieve[i] = false
... | 45Wieferich primes | 17swift | fi1dk |
import scala.swing.{ MainFrame, SimpleSwingApplication }
import scala.swing.Swing.pair2Dimension
object WindowExample extends SimpleSwingApplication {
def top = new MainFrame {
title = "Hello!"
centerOnScreen
preferredSize = ((200, 150))
}
} | 42Window creation/X11 | 16scala | k72hk |
use strict;
use XML::Mini::Document;
my @students = ( [ "April", "Bubbly: I'm > Tam and <= Emily" ],
[ "Tam O'Shanter", "Burns: \"When chapman billies leave the street ...\"" ],
[ "Emily", "Short & shrift" ]
);
my $doc = XML::Mini::Document->new();
my $root = $doc->getRoot();
my $... | 34XML/Output | 2perl | yz36u |
import java.util.ArrayList;
import java.util.List;
public class WeirdNumbers {
public static void main(String[] args) {
int n = 2; | 47Weird numbers | 9java | guf4m |
package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
} | 46Window creation | 0go | 743r2 |
import groovy.swing.SwingBuilder
new SwingBuilder().frame(title:'My Window', size:[200,100]).show() | 46Window creation | 7groovy | ulnv9 |
package main
import (
"fmt"
"strings"
)
func wrap(text string, lineWidth int) (wrapped string) {
words := strings.Fields(text)
if len(words) == 0 {
return
}
wrapped = words[0]
spaceLeft := lineWidth - len(wrapped)
for _, word := range words[1:] {
if len(word)+1 > spaceL... | 44Word wrap | 0go | jgm7d |
(() => {
'use strict'; | 47Weird numbers | 10javascript | k7yhq |
(second (re-find #" (\d{1,2}:\d{1,2}:\d{1,2}) UTC" (slurp "http://tycho.usno.navy.mil/cgi-bin/timer.pl"))) | 49Web scraping | 6clojure | 29sl1 |
(defn count-words [file n]
(->> file
slurp
clojure.string/lower-case
(re-seq #"\w+")
frequencies
(sort-by val >)
(take n))) | 50Word frequency | 6clojure | r5ng2 |
import Graphics.HGL
aWindow = runGraphics $
withWindow_ "Rosetta Code task: Creating a window" (300, 200) $ \ w -> do
drawInWindow w $ text (100, 100) "Hello World"
getKey w | 46Window creation | 8haskell | 8q70z |
def wordWrap(text, length = 80) {
def sb = new StringBuilder()
def line = ''
text.split(/\s/).each { word ->
if (line.size() + word.size() > length) {
sb.append(line.trim()).append('\n')
line = ''
}
line += " $word"
}
sb.append(line.trim()).toString()... | 44Word wrap | 7groovy | 52tuv |
null | 47Weird numbers | 11kotlin | 298li |
use strict;
use warnings;
for my $tuple ([" ", 2], ["_", 1], [" ", 1], ["\\", 1], [" ", 11], ["|", 1], ["\n", 1],
[" ", 1], ["|", 1], [" ", 3], ["|", 1], [" ", 1], ["_", 1], [" ", 1], ["\\", 1], [" ", 2], ["_", 2], ["|", 1], [" ", 1], ["|", 1], ["\n", 1],
[" ", 1], ["_", 3], ["/", 1], [... | 37Write language name in 3D ASCII | 2perl | 0xes4 |
ss =
concat
[ "In olden times when wishing still helped one, there lived a king"
, "whose daughters were all beautiful, but the youngest was so beautiful"
, "that the sun itself, which has seen so much, was astonished whenever"
, "it shone in her face. Close by the king's castle lay a great dark"
... | 44Word wrap | 8haskell | osk8p |
>>> from xml.etree import ElementTree as ET
>>> from itertools import izip
>>> def characterstoxml(names, remarks):
root = ET.Element()
for name, remark in izip(names, remarks):
c = ET.SubElement(root, , {'name': name})
c.text = remark
return ET.tostring(root)
>>> print characterstoxml(
names = [, , ],
remark... | 34XML/Output | 3python | m36yh |
function make(n, d)
local a = {}
for i=1,n do
table.insert(a, d)
end
return a
end
function reverse(t)
local n = #t
local i = 1
while i < n do
t[i],t[n] = t[n],t[i]
i = i + 1
n = n - 1
end
end
function tail(list)
return { select(2, unpack(list)) }
end... | 47Weird numbers | 1lua | vco2x |
package main
import (
"bytes"
"fmt"
"io/ioutil"
"strings"
)
var rows, cols int | 48Wireworld | 0go | lmscw |
import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
} | 46Window creation | 9java | epva5 |
window.open("webpage.html", "windowname", "width=800,height=600"); | 46Window creation | 10javascript | 0xrsz |
library(XML)
char2xml <- function(names, remarks){
tt <- xmlHashTree()
head <- addNode(xmlNode("CharacterRemarks"), character(), tt)
node <- list()
for (i in 1:length(names)){
node[[i]] <- addNode(xmlNode("Character", attrs=c(name=names[i])), head, tt)
addNode(xmlTextNode(remarks[i]), node[[i]], tt)
}
return(... | 34XML/Output | 13r | zdfth |
import Data.List
import Control.Monad
import Control.Arrow
import Data.Maybe
states=" Ht."
shiftS=" t.."
borden bc xs = bs: (map (\x -> bc:(x++[bc])) xs) ++ [bs]
where r = length $ head xs
bs = replicate (r+2) bc
take3x3 = ap ((.). taken. length) (taken. length. head) `ap` borden '*'
where taken n = ... | 48Wireworld | 8haskell | 1k9ps |
import javax.swing.JFrame
fun main(args: Array<String>) {
JFrame("Title").apply {
setSize(800, 600)
defaultCloseOperation = JFrame.EXIT_ON_CLOSE
isVisible = true
}
} | 46Window creation | 11kotlin | k7mh3 |
use strict;
use feature 'say';
use List::Util 'sum';
use POSIX 'floor';
use Algorithm::Combinatorics 'subsets';
use ntheory <is_prime divisors>;
sub abundant {
my($x) = @_;
my $s = sum( my @l = is_prime($x) ? 1 : grep { $x != $_ } divisors($x) );
$s > $x ? ($s, sort { $b <=> $a } @l) : ();
}
my(@weird,$n... | 47Weird numbers | 2perl | sw4q3 |
py = '''\
'''
lines = py.replace('
for i, l in enumerate(lines):
print( ' ' * (len(lines) - i) + l) | 37Write language name in 3D ASCII | 3python | 8qw0o |
package rosettacode;
import java.util.StringTokenizer;
public class WordWrap
{
int defaultLineWidth=80;
int defaultSpaceWidth=1;
void minNumLinesWrap(String text)
{
minNumLinesWrap(text,defaultLineWidth);
}
void minNumLinesWrap(String text,int LineWidth)
{
StringTokenizer ... | 44Word wrap | 9java | w14ej |
use utf8;
use XML::Simple;
my $ref = XMLin('<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
<Pet Type="... | 35XML/Input | 2perl | 4vv5d |
local iup = require "iuplua"
iup.dialog{
title = "Window";
iup.vbox{
margin = "10x10";
iup.label{title = "A window"}
}
}:show()
iup.MainLoop() | 46Window creation | 1lua | bj9ka |
function wrap (text, limit) {
if (text.length > limit) { | 44Word wrap | 10javascript | 8qh0l |
require 'rexml/document'
include REXML
remarks = {
%q(April) => %q(Bubbly: I'm > Tam and <= Emily),
%q(Tam O'Shanter) => %q(Burns: ),
%q(Emily) => %q(Short & shrift),
}
doc = Document.new
root = doc.add_element()
remarks.each do |name, remark|
root.add_element(, {'Name' => name}).add_text(rema... | 34XML/Output | 14ruby | cym9k |
'''Weird numbers'''
from itertools import chain, count, islice, repeat
from functools import reduce
from math import sqrt
from time import time
def weirds():
'''Non-finite stream of weird numbers.
(Abundant, but not semi-perfect)
OEIS: A006037
'''
def go(n):
ds = descPropDivs(n)
... | 47Weird numbers | 3python | 0xgsq |
<!DOCTYPE html><html><head><meta charset="UTF-8">
<title>Wireworld</title>
<script src="wireworld.js"></script></head><body>
<input type='file' accept='text/plain' onchange='openFile( event )' />
<br /></body></html> | 48Wireworld | 9java | 74trj |
extern crate xml;
use std::collections::HashMap;
use std::str;
use xml::writer::{EmitterConfig, XmlEvent};
fn characters_to_xml(characters: HashMap<String, String>) -> String {
let mut output: Vec<u8> = Vec::new();
let mut writer = EmitterConfig::new()
.perform_indent(true)
.create_writer(&mu... | 34XML/Output | 15rust | lm9cc |
val names = List("April", "Tam O'Shanter", "Emily")
val remarks = List("Bubbly: I'm > Tam and <= Emily", """Burns: "When chapman billies leave the street ..."""", "Short & shrift")
def characterRemarks(names: List[String], remarks: List[String]) = <CharacterRemarks>
{ names zip remarks map { case (name, remark) => ... | 34XML/Output | 16scala | ul2v8 |
<?php
$data = '<Students>
<Student Name= Gender= DateOfBirth= />
<Student Name= Gender= DateOfBirth= />
<Student Name= Gender= DateOfBirth= />
<Student Name= Gender= DateOfBirth=>
<Pet Type= Name= />
</Student>
<Student DateOfBirth= Gender= Name= />
</Students>';
$xml = new XMLReader();
$xml->xml( $d... | 35XML/Input | 12php | i00ov |
<!DOCTYPE html><html><head><meta charset="UTF-8">
<title>Wireworld</title>
<script src="wireworld.js"></script></head><body>
<input type='file' accept='text/plain' onchange='openFile( event )' />
<br /></body></html> | 48Wireworld | 10javascript | phmb7 |
text = <<EOS
EOS
def banner3D_1(text, shift=-1)
txt = text.each_line.map{|line| line.gsub('
offset = Array.new(txt.size){|i| * shift.abs * i}
offset.reverse! if shift < 0
puts offset.zip(txt).map(&:join)
end
banner3D_1(text)
puts
def banner3D_2(text, shift=-2)
txt... | 37Write language name in 3D ASCII | 14ruby | i0qoh |
package main
import (
"bytes"
"encoding/xml"
"fmt"
"io"
"net/http"
"regexp"
"time"
)
func main() {
resp, err := http.Get("http: | 49Web scraping | 0go | 1kmp5 |
package main
import (
"fmt"
"io/ioutil"
"log"
"regexp"
"sort"
"strings"
)
type keyval struct {
key string
val int
}
func main() {
reg := regexp.MustCompile(`\p{Ll}+`)
bs, err := ioutil.ReadFile("135-0.txt")
if err != nil {
log.Fatal(err)
}
text := strings.T... | 50Word frequency | 0go | swvqa |
null | 44Word wrap | 11kotlin | bjlkb |
pub fn char_from_id(id: u8) -> char {
[' ', '#', '/', '_', 'L', '|', '\n'][id as usize]
}
const ID_BITS: u8 = 3;
pub fn decode(code: &[u8]) -> String {
let mut ret = String::new();
let mut carry = 0;
let mut carry_bits = 0;
for &b in code {
let mut bit_pos = ID_BITS - carry_bits;
l... | 37Write language name in 3D ASCII | 15rust | n8si4 |
def ASCII3D = {
val name = """
*
** ** * * *
* * * * * * *
* * * * * * *
* * *** * ***
* * * * * * *
* * * * * * *
** ** * * *** * *
*
*
""" | 37Write language name in 3D ASCII | 16scala | tnofb |
def time = "unknown"
def text = new URL('http: | 49Web scraping | 7groovy | jgt7o |
import Data.List
import Network.HTTP (simpleHTTP, getResponseBody, getRequest)
tyd = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
readUTC = simpleHTTP (getRequest tyd)>>=
fmap ((!!2).head.dropWhile ("UTC"`notElem`).map words.lines). getResponseBody>>=putStrLn | 49Web scraping | 8haskell | tnkf7 |
def topWordCounts = { String content, int n ->
def mapCounts = [:]
content.toLowerCase().split(/\W+/).each {
mapCounts[it] = (mapCounts[it] ?: 0) + 1
}
def top = (mapCounts.sort { a, b -> b.value <=> a.value }.collect{ it })[0..<n]
println "Rank Word Frequency\n==== ==== ========="
(0..<... | 50Word frequency | 7groovy | abm1p |
def divisors(n)
divs = [1]
divs2 = []
i = 2
while i * i <= n
if n % i == 0 then
j = (n / i).to_i
divs.append(i)
if i!= j then
divs2.append(j)
end
end
i = i + 1
end
divs2 += divs.reverse
return divs2
en... | 47Weird numbers | 14ruby | os78v |
module Main where
import Control.Category
import Data.Char
import Data.List
import Data.Ord
import System.IO
import System.Environment
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import qualified Data.IntMap.Strict as IM
import Data.Text (Text)
im... | 50Word frequency | 8haskell | 96emo |
local map = {{'t', 'H', '.', '.', '.', '.', '.', '.', '.', '.', '.'},
{'.', ' ', ' ', ' ', '.'},
{' ', ' ', ' ', '.', '.', '.'},
{'.', ' ', ' ', ' ', '.'},
{'H', 't', '.', '.', ' ', '.', '.', '.', '.', '.', '.'}}
function step(map)
local next = {}
for i = 1, ... | 48Wireworld | 1lua | 52iu6 |
import xml.dom.minidom
doc =
doc = xml.dom.minidom.parseString(doc)
for i in doc.getElementsByTagName():
print i.getAttribute() | 35XML/Input | 3python | guu4h |
SELECT ' SSS\ ' AS s, ' QQQ\ ' AS q, 'L\ ' AS l FROM dual
UNION ALL SELECT 'S \|', 'Q Q\ ', 'L | ' FROM dual
UNION ALL SELECT '\SSS ', 'Q Q |', 'L | ' FROM dual
UNION ALL SELECT ' \ S\', 'Q Q Q |', 'L | ' from dual
union all select ' SSS |', ... | 37Write language name in 3D ASCII | 19sql | 6td3m |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class WebTime{
public static void main(String[] args){
try{
URL address = new URL(
"http: | 49Web scraping | 9java | 8q406 |
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class WordCount {
public s... | 50Word frequency | 9java | tnhf9 |
use Tk;
MainWindow->new();
MainLoop; | 46Window creation | 2perl | 3fezs |
function splittokens(s)
local res = {}
for w in s:gmatch("%S+") do
res[#res+1] = w
end
return res
end
function textwrap(text, linewidth)
if not linewidth then
linewidth = 75
end
local spaceleft = linewidth
local res = {}
local line = {}
for _, word in ipairs(sp... | 44Word wrap | 1lua | ph2bw |
library(XML)
str <- readLines(tc <- textConnection('<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
<Pe... | 35XML/Input | 13r | vcc27 |
var req = new XMLHttpRequest();
req.onload = function () {
var re = /[JFMASOND].+ UTC/; | 49Web scraping | 10javascript | fihdg |
my @doors;
for my $pass (1 .. 100) {
for (1 .. 100) {
if (0 == $_ % $pass) {
$doors[$_] = not $doors[$_];
};
};
};
print "Door $_ is ", $doors[$_] ? "open" : "closed", "\n" for 1 .. 100; | 21100 doors | 2perl | t5fg |
null | 49Web scraping | 11kotlin | w1lek |
null | 50Word frequency | 11kotlin | os48z |
import Tkinter
w = Tkinter.Tk()
w.mainloop() | 46Window creation | 3python | 6tw3w |
win <- tktoplevel() | 46Window creation | 13r | fipdc |
local http = require("socket.http") | 49Web scraping | 1lua | xa2wz |
null | 50Word frequency | 1lua | i0got |
my @f = ([],(map {chomp;['',( split // ),'']} <>),[]);
for (1 .. 10) {
print join "", map {"@$_\n"} @f;
my @a = ([]);
for my $y (1 .. $
my $r = $f[$y];
my $rr = [''];
for my $x (1 .. $
my $c = $r->[$x];
push @$rr,
$c eq 'H' ? 't' :
$c eq 't' ? '.' :
$c eq '.' ? (join('', map {"@{$f[$_]}[$x-1... | 48Wireworld | 2perl | 8qg0w |
require 'rexml/document'
include REXML
doc = Document.new(File.new())
doc.each_recursive do |node|
puts node.attributes[] if node.name ==
end
doc.each_element() {|node| puts node.attributes[]} | 35XML/Input | 14ruby | 744ri |
require 'tk'
window = TkRoot::new()
window::mainloop() | 46Window creation | 14ruby | m3qyj |
$desc = 'tH.........
. .
........
. .
Ht.. ......
..
tH.... .......
..
..
tH..... ......
..';
$steps = 30;
$world = array(array());
$row = 0;
$col = 0;
foreach(str_split($desc) as $i){
switch($i){
case :
$row++;
$col = 0;
$w... | 48Wireworld | 12php | 4vn5n |
use winit::event::{Event, WindowEvent}; | 46Window creation | 15rust | 96smm |
import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
} | 46Window creation | 16scala | 29olb |
my $s = "In olden times when wishing still helped one, there lived a king
whose daughters were all beautiful, but the youngest was so beautiful
that the sun itself, which has seen so much, was astonished whenever
it shone in her face. Close-by-the-king's-castle-lay-a-great-dark
forest, and under an old lime-tree in th... | 44Word wrap | 2perl | 6tq36 |
extern crate xml; | 35XML/Input | 15rust | jgg72 |
val students =
<Students>
<Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
<Student Name="Bob" Gender="M" DateOfBirth="1990-03-04" />
<Student Name="Chad" Gender="M" DateOfBirth="1991-05-06" />
<Student Name="Dave" Gender="M" DateOfBirth="1992-07-08">
<Pet Type="dog" Name="Rover" ... | 35XML/Input | 16scala | bjjk6 |
<?php
for ($i = 1; $i <= 100; $i++) {
$root = sqrt($i);
$state = ($root == ceil($root))? 'open' : 'closed';
echo ;
}
?> | 21100 doors | 12php | kohv |
'''
Wireworld implementation.
'''
from io import StringIO
from collections import namedtuple
from pprint import pprint as pp
import copy
WW = namedtuple('WW', 'world, w, h')
head, tail, conductor, empty = allstates = 'Ht. '
infile = StringIO('''\
tH.........
. .
...
. .
Ht.. ......\
''')
def readfile(f):
... | 48Wireworld | 3python | osr81 |
<?php
$text = <<<ENDTXT
If there's anything you need
All you have to do is say
You know you satisfy everything in me
We shouldn't waste a single day
So don't stop me falling
It's destiny calling
A power I just can't deny
It's never changing
Can't you hear me, I'm saying
I want you for the rest of my life
Together fo... | 44Word wrap | 12php | 1kvpq |
$top = 10;
open $fh, "<", '135-0.txt';
($text = join '', <$fh>) =~ tr/A-Z/a-z/
or die "Can't open '135-0.txt': $!\n";
@matcher = (
qr/[a-z]+/,
qr/\w+/,
qr/[a-z0-9]+/,
);
for $reg (@matcher) {
print "\nTop $top using regex: " . $reg . "\n";
@matches = $text =~ /$reg/g;
my %w... | 50Word frequency | 2perl | gui4e |
<?php
preg_match_all('/\w+/', file_get_contents($argv[1]), $words);
$frecuency = array_count_values($words[0]);
arsort($frecuency);
echo ;
$i = 1;
foreach ($frecuency as $word => $count) {
echo $i . . $word . . $count . ;
if ($i >= 10) {
break;
}
$i++;
} | 50Word frequency | 12php | n8rig |
use LWP::Simple;
my $url = 'http://tycho.usno.navy.mil/cgi-bin/timer.pl';
get($url) =~ /<BR>(.+? UTC)/
and print "$1\n"; | 49Web scraping | 2perl | lmqc5 |
use std::str::FromStr;
pub enum State {
Empty,
Conductor,
ElectronTail,
ElectronHead,
}
impl State {
fn next(&self, e_nearby: usize) -> State {
match self {
State::Empty => State::Empty,
State::Conductor => {
if e_nearby == 1 || e_nearby == 2 {
... | 48Wireworld | 14ruby | n8jit |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.