Looking for an inspiration? Below you will find public programs submitted by other users.

Filter by: All Bash C C# C++ 4.9.2 C++14 Haskell Java Java7 Objective-C Pascal (fpc) Pascal (gpc) Perl PHP Python Python 3 Ruby SQL VB.NET Ada Assembler Assembler AWK (gawk) AWK (mawk) bc Brainf**k C++ 4.3.2 C99 strict CLIPS Clojure COBOL COBOL 85 Common Lisp (clisp) D D (dmd) Erlang F# Factor Falcon Forth Fortran Go Groovy Icon Intercal JavaScript (rhino) JavaScript (spidermonkey) Lua Nemerle Nice Nimrod Node.js Ocaml Octave Oz PARI/GP Perl 6 Pike Prolog (gnu) Prolog (swi) Python (Pypy) R Scala Scheme (chicken) Scheme (guile) Smalltalk Tcl Text Unlambda Whitespace

#ISsKT3 Scala 1 hour ago
Success
  1. object Main extends App
  2. {
  3. val x = if (false) 5 else "yoba"
  4. println { x }
  5. println { if (false) 5 else '5' }
  6. println { val x = if (false) 5 else '5' ; x }
  7. }
#6JMOPD Scala 1 hour ago
Success
  1. object Main extends App
  2. {
  3. val x = if (false) 5 else "5"
  4. println { x }
  5. println { if (false) 5 else '5' }
  6. println { val x = if (false) 5 else '5' ; x }
  7. }
#07pIHf Scala 2 hours ago
Success
  1. object Main extends App {
  2. val a =(x:Int) => x + 1
  3. val b = {x:Int => x + 1}
  4.  
  5. println(a.apply(1))
  6. println(b.apply(2))
  7. println(a(1))
  8. println(b(2))
#i8t6gJ Scala 2 hours ago
Success
  1. object Main extends App {
  2. object MySingleton {
  3. def foo = 19
  4. }
  5.  
  6. val a = MySingleton
  7. val b = MySingleton
  8.  
  9. println(a == b) //object equality
#OyVQrR Scala 3 hours ago
Runtime error
  1. object Main extends App {
  2. println(io.Source.fromURL("http://f...content-available-to-author-only...e.com/").getLines.find(l => l.contains("h2")).headOption.get.replaceAll("""(<(/?)(h2|mark)>)""", "").trim)
  3. }
#5oon8L Scala 4 hours ago
Not running
  1. trait Similarity {
  2. def isSimilar(x: Any): Boolean
  3. def isNotSimilar(x: Any): Boolean = !isSimilar(x)
  4. }
  5.  
  6. class Point(xc: Int, yc: Int) extends Similarity {
  7. var x: Int = xc
  8. var y: Int = yc
  9. def isSimilar(obj: Any) =
#m1o3e5 Scala 4 hours ago
Not running
  1. import java.util.{Date, Locale}
  2. import java.text.DateFormat._
  3.  
  4. object Today extends Application {
  5.  
  6. override def main(args: Array[String]) {
  7.  
  8. val now = new Date
  9. val frenchDateFormatter = getDateInstance(LONG, Locale.FRANCE)
#tvkF2N Scala 4 hours ago
Not running
  1. object TimerExample {
  2. /** Runs the passed in function pausing approxmimately one second in between calls.
  3.   * as long as the function returns true.
  4.   */
  5. def oncePerSecond(callback: () => Boolean) {
  6. while(callback()) {
  7. Thread sleep 1000
  8. }
  9. }
#fQ5GUt Scala 4 hours ago
Not running
  1. /* Example of case class */
  2.  
  3.  
  4. case class Var(name: String) extends Term
  5. case class Fun(arg: String, body: Term) extends Term
  6. case class App(f: Term, v: Term) extends Term
  7.  
  8. object TermTest extends Application {
#ley4vN Scala 4 hours ago
Not running
  1. object HelloWorld extends Application {
  2. println("Hello, World!")
  3. }
#hKIE0X Scala 4 hours ago
Not running
  1. class HelloClass {
  2. def inClass() {
  3. println("In class")
  4. }
  5. }
  6.  
  7. object HelloObjectPlusClass {
  8. println("In object")
#l6bEpl Scala 4 hours ago
Not running
  1. object HelloObject {
  2. println("In object")
  3.  
  4. def main(args: Array[String]) {
  5. println("In main")
  6. }
  7.  
  8. }
#KZrwDY Scala 4 hours ago
Not running
  1. object HelloClass {
  2.  
  3. abstract class Person {
  4. def name: String
  5. def age: Int
  6.  
  7. def getName(): String = {
  8. name
  9. }
#QNjnMp Scala 4 hours ago
Not running
  1. object FibonacciLister {
  2. def main(args: Array[String]) {
  3. val n = args(0).toInt
  4. var (a, b) = (0, 1)
  5. while (b <= n) {
  6. print(b + " ")
  7. var olda = a
  8. a = b
  9. b = a + b
#VThTPO Scala 4 hours ago
Not running
  1. object Main {
  2. class MyString(val jString: String) {
  3. private var extraData = ""
  4. override def toString = jString + extraData
  5. }
  6. object MyString {
  7. def apply(base:String, extras:String) {
  8. val s = new MyString(base)
  9. s.extraData = extras
#3xn5IG Scala 4 hours ago
Not running
  1. object CaseClassInheritance {
  2. abstract class Person {
  3. def name: String
  4. def age: Int
  5. // address and other properties
  6. // methods (ideally only accessors since it is a case class)
  7. def getName(): String = {
  8. return name
  9. }
#Fieurq Scala 5 hours ago
Success
  1. object Main extends App {
  2. val a = 2
  3. val d = 3.1
  4. val res = d + a
  5. System.out.println(res);
  6.  
  7. }
#w088Vr Scala 8 hours ago
Compilation error
  1.  
  2. object Main extends App {
  3. // your code goes here
  4. case class Author(name: string, surname: string)
  5. case class Book(title: string, authors: List[Author])
  6. // def main (args:Array[String])= {
  7. val auth1 = new Author("Marco Tullio", "Cicerone")
  8. val auth2 = new Author("Tizio", "Seneca")
  9. val book1 = new Book("Gallia 2", List(auth1, auth2))
#9PJcvu Scala 8 hours ago
Success
  1. object Main extends App {
  2.  
  3. val l = List(1,2,3,4,5)
  4. var i=0
  5. val a= l.map(x=>(i=i+1,2))
  6. println(a)
  7.  
  8. }
#sYtPl9 Scala 10 hours ago
Compilation error
  1. 2 + 4
#JM8WNX Scala 11 hours ago
Success
  1. import scala.concurrent.duration._
  2.  
  3. object Main extends App {
  4. val input = Stream.continually(readLine()).takeWhile(null ne).map(_.toInt)
  5.  
  6. def products(stream: Stream[Int]): Stream[Int] = stream match {
  7. case Stream.Empty
  8. Stream.Empty
  9.  
#drjDYw Scala 12 hours ago
Success
  1. object Main extends App {
  2. // your code goes here
  3. println("Hola mundo!!!")
  4. }
#YMIwlZ Scala 12 hours ago
Success
  1. import scala.concurrent.duration._
  2.  
  3. object Main extends App {
  4. val input = Stream.continually(readLine()).takeWhile(null ne).map(_.toInt)
  5.  
  6. def products(stream: Stream[Int]): Stream[Int] = stream match {
  7. case Stream.Empty
  8. Stream.Empty
  9.  
#mtFNRI Scala 14 hours ago
Success
  1. import java.time._
  2. import java.time.format._
  3. import scala.util.Try
  4.  
  5. object Main extends App {
  6. val formats = Seq("yyyy-MM-dd", "dd-MM-yyyy").map(DateTimeFormatter.ofPattern)
  7. val strings = Seq("17-10-1984@", "1987-03-23")
  8.  
  9. val dates = strings.flatMap { date ⇒
#NUghMp Scala 15 hours ago
Compilation error
  1. object A {
  2. val hoge = 100
  3. }
  4.  
  5. trait B {
  6. import A._
  7. }
  8.  
#NxnEr3 Scala 16 hours ago
Success
  1. import java.time._
  2. import java.time.format._
  3. import scala.util.Try
  4.  
  5. object Main extends App {
  6. val formats = Seq("yyyy-MM-dd", "dd-MM-yyyy").map(DateTimeFormatter.ofPattern)
  7. val strings = Seq("17-10-1984", "1987-03-23")
  8.  
  9. val dates = strings.flatMap { date ⇒
#8192rt Scala 19 hours ago
Compilation error
  1. object test {
  2. def gcd(a:Int , b:Int) : Int = if(b==0) a else gcd(b,a%b)
  3. def main(args: Array[String])
  4. gcd(70,49)
  5. }
#2uGQme Scala 21 hours ago
Success
  1. object Main {
  2. // your code goes here
  3. def main(args: Array[String]) {
  4. println("trial and test")
  5. }
  6. }
#oTXd5g Scala 21 hours ago
Compilation error
  1. object Main extends App {
  2. def main(args[]: String) {
  3. println("trial")
  4. }
  5. // your code goes here
  6. }
#B7niig Scala 1 day ago
Success
  1. object Main extends App {
  2. println("Hello world!")
  3. println(10)
  4.  
  5. }