From 9b5217c82b923dce4eca80b7a0a0dfed7af0df08 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sat, 18 Apr 2020 17:57:23 -0700 Subject: [PATCH 001/272] Remove Scala Section. (#125) --- languages/scala/CaseClassInheritance.scala | 24 ---- languages/scala/CompanianObject.scala | 21 --- languages/scala/FibonacciLister.scala | 13 -- languages/scala/HelloClassCaseClass.scala | 29 ---- languages/scala/HelloObject.scala | 8 -- languages/scala/HelloObjectPlusClass.scala | 15 --- languages/scala/HelloWorld.scala | 3 - languages/scala/InteractiveScala.sc | 38 ------ languages/scala/ScalaBigInt.scala | 11 -- languages/scala/TermTest.scala | 35 ----- languages/scala/TheBasics.sc | 146 --------------------- languages/scala/Today.scala | 16 --- languages/scala/TraitsTest.scala | 21 --- languages/scala/timer.scala | 17 --- source/index.rst | 8 -- source/scala/CaseClassInheritance.rst | 34 ----- source/scala/CompanianObject.rst | 34 ----- source/scala/FibonacciLister.rst | 34 ----- source/scala/HelloClassCaseClass.rst | 34 ----- source/scala/HelloObject.rst | 34 ----- source/scala/HelloObjectPlusClass.rst | 34 ----- source/scala/HelloWorld.rst | 34 ----- source/scala/Interactive.rst | 72 ---------- source/scala/TermTest.rst | 34 ----- source/scala/Timer.rst | 34 ----- source/scala/Today.rst | 34 ----- source/scala/TraitsTest.rst | 34 ----- source/scala/index.rst | 28 ---- 28 files changed, 879 deletions(-) delete mode 100644 languages/scala/CaseClassInheritance.scala delete mode 100644 languages/scala/CompanianObject.scala delete mode 100644 languages/scala/FibonacciLister.scala delete mode 100644 languages/scala/HelloClassCaseClass.scala delete mode 100644 languages/scala/HelloObject.scala delete mode 100644 languages/scala/HelloObjectPlusClass.scala delete mode 100644 languages/scala/HelloWorld.scala delete mode 100644 languages/scala/InteractiveScala.sc delete mode 100644 languages/scala/ScalaBigInt.scala delete mode 100644 languages/scala/TermTest.scala delete mode 100644 languages/scala/TheBasics.sc delete mode 100644 languages/scala/Today.scala delete mode 100644 languages/scala/TraitsTest.scala delete mode 100644 languages/scala/timer.scala delete mode 100644 source/scala/CaseClassInheritance.rst delete mode 100644 source/scala/CompanianObject.rst delete mode 100644 source/scala/FibonacciLister.rst delete mode 100644 source/scala/HelloClassCaseClass.rst delete mode 100644 source/scala/HelloObject.rst delete mode 100644 source/scala/HelloObjectPlusClass.rst delete mode 100644 source/scala/HelloWorld.rst delete mode 100644 source/scala/Interactive.rst delete mode 100644 source/scala/TermTest.rst delete mode 100644 source/scala/Timer.rst delete mode 100644 source/scala/Today.rst delete mode 100644 source/scala/TraitsTest.rst delete mode 100644 source/scala/index.rst diff --git a/languages/scala/CaseClassInheritance.scala b/languages/scala/CaseClassInheritance.scala deleted file mode 100644 index 35e06c72..00000000 --- a/languages/scala/CaseClassInheritance.scala +++ /dev/null @@ -1,24 +0,0 @@ -object CaseClassInheritance { - abstract class Person { - def name: String - def age: Int - // address and other properties - // methods (ideally only accessors since it is a case class) - def getName(): String = { - return name - } - } - - case class Employer(val name: String, val age: Int, val taxno: Int) - extends Person - - case class Employee(val name: String, val age: Int, val salary: Int) - extends Person - - case class PersonA(val name: String, val age: Int, val salary: Int) extends Person - - def main(args: Array[String]) { - val p = PersonA("Senthil",10,42) - println(p.getName) - } -} diff --git a/languages/scala/CompanianObject.scala b/languages/scala/CompanianObject.scala deleted file mode 100644 index 0140e636..00000000 --- a/languages/scala/CompanianObject.scala +++ /dev/null @@ -1,21 +0,0 @@ -object Main { - class MyString(val jString: String) { - private var extraData = "" - override def toString = jString + extraData - } - object MyString { - def apply(base:String, extras:String) { - val s = new MyString(base) - s.extraData = extras - s - } - def apply(base:String) = new MyString(base) - } - - def main(args: Array[String]) { - println(MyString("hello", "world")) - println(MyString("hello")) - } - -} - diff --git a/languages/scala/FibonacciLister.scala b/languages/scala/FibonacciLister.scala deleted file mode 100644 index 781da46d..00000000 --- a/languages/scala/FibonacciLister.scala +++ /dev/null @@ -1,13 +0,0 @@ -object FibonacciLister { - def main(args: Array[String]) { - val n = args(0).toInt - var (a, b) = (0, 1) - while (b <= n) { - print(b + " ") - var olda = a - a = b - b = a + b - } - println - } -} diff --git a/languages/scala/HelloClassCaseClass.scala b/languages/scala/HelloClassCaseClass.scala deleted file mode 100644 index 91c86fbb..00000000 --- a/languages/scala/HelloClassCaseClass.scala +++ /dev/null @@ -1,29 +0,0 @@ -object HelloClass { - - abstract class Person { - def name: String - def age: Int - - def getName(): String = { - name - } - - def getAge(): Int = { - age - } - } - - case class PersonA(val name: String, val age: Int, val salary: Int) extends Person - - - -} - -object HelloObjectPlusClass { - - def main(args: Array[String]) { - //val p = HelloClass - val x = HelloClass.PersonA("Senthil", 10, 42) - println(x.getName) - } -} diff --git a/languages/scala/HelloObject.scala b/languages/scala/HelloObject.scala deleted file mode 100644 index 1ee1051c..00000000 --- a/languages/scala/HelloObject.scala +++ /dev/null @@ -1,8 +0,0 @@ -object HelloObject { - println("In object") - - def main(args: Array[String]) { - println("In main") - } - -} diff --git a/languages/scala/HelloObjectPlusClass.scala b/languages/scala/HelloObjectPlusClass.scala deleted file mode 100644 index 86f73bff..00000000 --- a/languages/scala/HelloObjectPlusClass.scala +++ /dev/null @@ -1,15 +0,0 @@ -class HelloClass { - def inClass() { - println("In class") - } -} - -object HelloObjectPlusClass { - println("In object") - - def main(args: Array[String]) { - println("In main") - val c = new HelloClass - c.inClass() - } -} diff --git a/languages/scala/HelloWorld.scala b/languages/scala/HelloWorld.scala deleted file mode 100644 index b64fd38d..00000000 --- a/languages/scala/HelloWorld.scala +++ /dev/null @@ -1,3 +0,0 @@ -object HelloWorld extends Application { - println("Hello, World!") -} diff --git a/languages/scala/InteractiveScala.sc b/languages/scala/InteractiveScala.sc deleted file mode 100644 index 32d3f708..00000000 --- a/languages/scala/InteractiveScala.sc +++ /dev/null @@ -1,38 +0,0 @@ -"Hello, World" -8 + 5 -8 * 5 + 2 -0.5 * 42 -"hello, " + 42 -"Hello, World".toLowerCase -42.toString -"Hello, World".toUpperCase -val answer = 8 * 5 + 2 -0.5 * answer -// answer = 0 -// error: reassignment to val -var count = 0 -count = 1 -val greeting: String = null -val greeting2: Any = "Hello" -1.to(10) -val xmax, ymax = 100 -1.toString() - -val a = 10 -val b = 20 -a.+(b) - -1 to 10 - -val x: BigInt = 123456790 -x * x * x -import scala.math._ -sqrt(2) -pow(2, 4) -min(3, Pi) -"Hello".distinct -"hello"(4) -"Hello".apply(4) -BigInt("1234567890") -BigInt.apply("1234567890") -"Harry".patch(1, "ung", 2) diff --git a/languages/scala/ScalaBigInt.scala b/languages/scala/ScalaBigInt.scala deleted file mode 100644 index ff2cfacf..00000000 --- a/languages/scala/ScalaBigInt.scala +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Exercises 6: Using BigInt compute 2 ^ 1024 - * - */ - -import scala.math._ - -object ScalaBigInt extends Application { - val res: BigInt = pow(2, 1024).toInt - println(res) -} diff --git a/languages/scala/TermTest.scala b/languages/scala/TermTest.scala deleted file mode 100644 index 6f2bd364..00000000 --- a/languages/scala/TermTest.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* Example of case class */ - -abstract class Term - -case class Var(name: String) extends Term -case class Fun(arg: String, body: Term) extends Term -case class App(f: Term, v: Term) extends Term - -object TermTest extends Application { - def printTerm(term: Term) { - term match { - case Var(n) => - print(n) - case Fun(x, b) => - print("^" + x + ".") - printTerm(b) - case App(f, v) => - Console.print("(") - printTerm(f) - print(" ") - printTerm(v) - print(")") - } - } - def isIdentityFun(term: Term): Boolean = term match { - case Fun(x, Var(y)) if x == y => true - case _ => false - } - val id = Fun("x", Var("x")) - val t = Fun("x", Fun("y", App(Var("x"), Var("y")))) - printTerm(t) - println - println(isIdentityFun(id)) - println(isIdentityFun(t)) -} diff --git a/languages/scala/TheBasics.sc b/languages/scala/TheBasics.sc deleted file mode 100644 index c841894d..00000000 --- a/languages/scala/TheBasics.sc +++ /dev/null @@ -1,146 +0,0 @@ -// In the Scala REPL, type 3 followed by the Tab Key. What -// methods can be applied? -// % - TODO skumaran - find usage -// & -// * -// + -// - -// / -// > -// >= -// >> -// >>> -//^ -// asInstanceOf - TODO skumaran - find usage. -// isInstanceOf -// toByte -// toChar -// toDouble -// toFloat -// toInt -// toLong -// toShort -// toString -// unary_+ -// unary_- -// unary_~ -// | - TODO skumaran - find usage -// Question 2 - In the scala REPL, compute the square root -// of 3, and then square that value. By how much does the -// result differ from 3? -import scala.math._ -val s = sqrt(3.0) -val d = s * s -3.0 - d // 4.440892098500626E-16 -/** - * Question 3: - * Are the res variables val or var? - * - * Answer: They are val. - */ - -// scala> sqrt(2.0) -// res39: Double = 1.4142135623730951 -// scala> res39 = 10.1 -// :11: error: reassignment to val -// res39 = 10.1 - - -/** - * Question 4: - * - * Scala lets you multiply a string with a number - try out - * "crazy" * 3 in REPL. - */ - -"crazy" * 3 -// res1: String = crazycrazycrazy -// http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.StringOps@*(n:Int):String - -/** - * Question 5: - * What does 10 max 2 mean? n which class is the max method defined? - * - * Answer: Returns 2 - * It is defined in RichInt - * http://www.scala-lang.org/api/current/index.html#scala.runtime.RichInt@max(that:Int):Int - * - */ - -10 max 2 -/** - * Question 6: - * Using BigInt, compute 2 power 1024 - */ - -val two = BigInt(2) -two.pow(1024) -/** - * Question 7: - * - * What do you need to import so that you can get a random prime as a - * probablePrime(100, Random), without any qualifiers before probablePrime - * and Random? - * - * import BigInt._ - * import scala.util._ - * probablePrime(100, Random) - */ - -import scala.BigInt._ -import scala.util._ -probablePrime(100, Random) -/** - * Question 8: - * - * One way to create a random file or directory names is to produce a random BigInt - * and convert it to base 36, yielding a string such as "qsnvxegege252dged". - * Poke around Scaladoc to find a way of doing this in Scala. - * - * Random BigInt with number of bits set. - * http://www.scala-lang.org/api/current/index.html#scala.math.BigInt$@apply(numbits:Int,rnd:scala.util.Random):scala.math.BigInt - * - * toString with a Radix - * http://www.scala-lang.org/api/current/index.html#scala.math.BigInt@toString(radix:Int):String - * - */ -BigInt(60, Random).toString(36) - -/** - * Question 9: - * - * How do you get the first character of a string in Scala? The last character? - * - * charAt method can be used to get the chars at position 0 and position length-1 - */ - -val str = BigInt(60, Random).toString(36) -str.charAt(0) -str.charAt(str.length-1) -str.take(1) -str.takeRight(1) - - -/** - * Question 10: - * - * What do the take, drop, takeRight and dropRight string functions do? - * What advantage or disadvantage do they have over using substring - * - * take, picks one character at a time from left and displays it - * takeRight, picks up one character from the Right and prints it. - * - * drop, drops the specified number of characters and creates a new string. - * dropRight, drops the specified number of characters to - * the Right and creates a new string. - * - * The difference from substring is, the startindex is automatically provided. - * - */ - - -val str2 = BigInt(60, Random).toString(36) -str2.charAt(0) -str2.charAt(str2.length-1) -str2.take(1) -str2.takeRight(1) diff --git a/languages/scala/Today.scala b/languages/scala/Today.scala deleted file mode 100644 index 0a732dc5..00000000 --- a/languages/scala/Today.scala +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.{Date, Locale} -import java.text.DateFormat._ - -object Today extends Application { - - override def main(args: Array[String]) { - - val now = new Date - val frenchDateFormatter = getDateInstance(LONG, Locale.FRANCE) - println(frenchDateFormatter format now) - println(getDateInstance(LONG, Locale.US) format now) - println(getDateInstance(SHORT, Locale.CHINA) format now) - } - -} - diff --git a/languages/scala/TraitsTest.scala b/languages/scala/TraitsTest.scala deleted file mode 100644 index 25882fa0..00000000 --- a/languages/scala/TraitsTest.scala +++ /dev/null @@ -1,21 +0,0 @@ -trait Similarity { - def isSimilar(x: Any): Boolean - def isNotSimilar(x: Any): Boolean = !isSimilar(x) -} - -class Point(xc: Int, yc: Int) extends Similarity { - var x: Int = xc - var y: Int = yc - def isSimilar(obj: Any) = - obj.isInstanceOf[Point] && - obj.asInstanceOf[Point].x == x -} - -object TraitsTest extends Application { - val p1 = new Point(2, 3) - val p2 = new Point(2, 4) - val p3 = new Point(3, 3) - println(p1.isNotSimilar(p2)) - println(p1.isNotSimilar(p3)) - println(p1.isNotSimilar(2)) -} diff --git a/languages/scala/timer.scala b/languages/scala/timer.scala deleted file mode 100644 index 99e25159..00000000 --- a/languages/scala/timer.scala +++ /dev/null @@ -1,17 +0,0 @@ -object TimerExample { - /** Runs the passed in function pausing approxmimately one second in between calls. - * as long as the function returns true. - */ - def oncePerSecond(callback: () => Boolean) { - while(callback()) { - Thread sleep 1000 - } - } - - /** Counts down from 0 to 1, approxmimately once per second. - */ - def main(args: Array[String]) { - var count = 10 - oncePerSecond(() => {println(count); count -= 1; count > 0}) - } -} diff --git a/source/index.rst b/source/index.rst index 49cc69ef..0cde9334 100644 --- a/source/index.rst +++ b/source/index.rst @@ -66,11 +66,3 @@ Java Programming Language :maxdepth: 3 java/index - -Scala Programming Language -========================== - -.. toctree:: - :maxdepth: 3 - - scala/index diff --git a/source/scala/CaseClassInheritance.rst b/source/scala/CaseClassInheritance.rst deleted file mode 100644 index 61aa6aef..00000000 --- a/source/scala/CaseClassInheritance.rst +++ /dev/null @@ -1,34 +0,0 @@ -====================== -Case Class Inheritance -====================== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/CaseClassInheritance.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/CaseClassInheritance.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`CaseClassInheritance.scala` - * :scala-better-explain:`CaseClassInheritance.rst` - diff --git a/source/scala/CompanianObject.rst b/source/scala/CompanianObject.rst deleted file mode 100644 index e41c675c..00000000 --- a/source/scala/CompanianObject.rst +++ /dev/null @@ -1,34 +0,0 @@ -================ -Companian Object -================ - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/CompanianObject.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/CompanianObject.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`CompanianObject.scala` - * :scala-better-explain:`CompanianObject.rst` - diff --git a/source/scala/FibonacciLister.rst b/source/scala/FibonacciLister.rst deleted file mode 100644 index 18dc3d46..00000000 --- a/source/scala/FibonacciLister.rst +++ /dev/null @@ -1,34 +0,0 @@ -================ -Fibonacci Lister -================ - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/FibonacciLister.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/FibonacciLister.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`FibonacciLister.scala` - * :scala-better-explain:`FibonacciLister.rst` - diff --git a/source/scala/HelloClassCaseClass.rst b/source/scala/HelloClassCaseClass.rst deleted file mode 100644 index 0bfc42bd..00000000 --- a/source/scala/HelloClassCaseClass.rst +++ /dev/null @@ -1,34 +0,0 @@ -====================== -Hello Class Case Class -====================== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/HelloClassCaseClass.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/HelloClassCaseClass.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`HelloClassCaseClass.scala` - * :scala-better-explain:`HelloClassCaseClass.rst` - diff --git a/source/scala/HelloObject.rst b/source/scala/HelloObject.rst deleted file mode 100644 index 898bf4a4..00000000 --- a/source/scala/HelloObject.rst +++ /dev/null @@ -1,34 +0,0 @@ -============ -Hello Object -============ - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/HelloObject.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/HelloObject.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`HelloObject.scala` - * :scala-better-explain:`HelloObject.rst` - diff --git a/source/scala/HelloObjectPlusClass.rst b/source/scala/HelloObjectPlusClass.rst deleted file mode 100644 index ee0e5737..00000000 --- a/source/scala/HelloObjectPlusClass.rst +++ /dev/null @@ -1,34 +0,0 @@ -======================= -Hello Object Plus Class -======================= - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/HelloObjectPlusClass.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/HelloObjectPlusClass.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`HelloObjectPlusClass.scala` - * :scala-better-explain:`HelloObjectPlusClass.rst` - diff --git a/source/scala/HelloWorld.rst b/source/scala/HelloWorld.rst deleted file mode 100644 index 2f79ef1e..00000000 --- a/source/scala/HelloWorld.rst +++ /dev/null @@ -1,34 +0,0 @@ -=========== -Hello World -=========== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/HelloWorld.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/HelloWorld.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`HelloWorld.scala` - * :scala-better-explain:`HelloWorld.rst` - diff --git a/source/scala/Interactive.rst b/source/scala/Interactive.rst deleted file mode 100644 index 231d0fc1..00000000 --- a/source/scala/Interactive.rst +++ /dev/null @@ -1,72 +0,0 @@ -========================== -Interactive Interpretation -========================== - -Question -======== - -Using Scala's Interactive Interpreter - -Solution -======== - -.. literalinclude:: ../../languages/scala/InteractiveScala.sc - :language: scala - :tab-width: 4 - -Explanation -=========== - -:: - - res0: String = Hello, World - res1: Int = 13 - res2: Int = 42 - res3: Double = 21.0 - res4: String = hello, 42 - res5: String = hello, world - res6: String = 42 - res7: String = HELLO, WORLD - answer: Int = 42 - res8: Double = 21.0 - - - count: Int = 0 - count: Int = 1 - greeting: String = null - greeting2: Any = Hello - res9: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - xmax: Int = 100 - ymax: Int = 100 - res10: String = 1 - - a: Int = 10 - b: Int = 20 - res11: Int = 30 - - res12: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) - - x: scala.math.BigInt = 123456790 - res13: scala.math.BigInt = 1881676417513891481839000 - import scala.math._ - res14: Double = 1.4142135623730951 - res15: Double = 16.0 - res16: Double = 3.0 - res17: String = Helo - res18: Char = o - res19: Char = o - res20: scala.math.BigInt = 1234567890 - res21: scala.math.BigInt = 1234567890 - res22: String = Hungry - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`Interactive.scala` - * :scala-better-explain:`Interactive.rst` - diff --git a/source/scala/TermTest.rst b/source/scala/TermTest.rst deleted file mode 100644 index 4d73eea5..00000000 --- a/source/scala/TermTest.rst +++ /dev/null @@ -1,34 +0,0 @@ -========= -Term Test -========= - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/TermTest.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/TermTest.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`TermTest.scala` - * :scala-better-explain:`TermTest.rst` - diff --git a/source/scala/Timer.rst b/source/scala/Timer.rst deleted file mode 100644 index 60196d5c..00000000 --- a/source/scala/Timer.rst +++ /dev/null @@ -1,34 +0,0 @@ -===== -Timer -===== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/timer.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/timer.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`timer.scala` - * :scala-better-explain:`Timer.rst` - diff --git a/source/scala/Today.rst b/source/scala/Today.rst deleted file mode 100644 index f71191a9..00000000 --- a/source/scala/Today.rst +++ /dev/null @@ -1,34 +0,0 @@ -===== -Today -===== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/Today.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/Today.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`Today.scala` - * :scala-better-explain:`Today.rst` - diff --git a/source/scala/TraitsTest.rst b/source/scala/TraitsTest.rst deleted file mode 100644 index ba3405a0..00000000 --- a/source/scala/TraitsTest.rst +++ /dev/null @@ -1,34 +0,0 @@ -=========== -Traits Test -=========== - -Question -======== - -ADDQUESTION - -Solution -======== - -.. literalinclude:: ../../languages/scala/TraitsTest.scala - :language: scala - :tab-width: 4 - -.. runcode:: ../../languages/scala/TraitsTest.scala - :language: scala - :codesite: ideone - -Explanation -=========== - - - - - - - -.. seealso:: - - * :scala-suggest-improve:`TraitsTest.scala` - * :scala-better-explain:`TraitsTest.rst` - diff --git a/source/scala/index.rst b/source/scala/index.rst deleted file mode 100644 index 818acc12..00000000 --- a/source/scala/index.rst +++ /dev/null @@ -1,28 +0,0 @@ -========================== -Scala Programming Examples -========================== - -This is Uthcode's Scala programming section, which illustrates how to do various -programing tasks using Scala. - -Programs -======== - -Our intention is to present the programs using -'Scala by Example and Scala for the Impatient' books here with explanation. - -.. toctree:: - :maxdepth: 1 - - CaseClassInheritance - CompanianObject - FibonacciLister - HelloClassCaseClass - HelloObject - HelloObjectPlusClass - HelloWorld - TermTest - Timer - Today - TraitsTest - Interactive From 4f9a7aec7609519010faea9b6a6522b9f98a3229 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 07:06:30 -0700 Subject: [PATCH 002/272] use the version reference to master. --- source/conf.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/conf.py b/source/conf.py index 5547782b..42c769fb 100644 --- a/source/conf.py +++ b/source/conf.py @@ -115,40 +115,40 @@ # :python-better-explain:`name.rst` extlinks = {'c-suggest-improve': - ('https://github.com/uthcode/learntosolveit/edit/version1/languages/cprogs/%s', + ('https://github.com/uthcode/learntosolveit/edit/master/languages/cprogs/%s', "Suggest a Code Improvement: "), 'c-better-explain': - ('https://github.com/uthcode/learntosolveit/edit/version1/source/cprogramming/%s', + ('https://github.com/uthcode/learntosolveit/edit/master/source/cprogramming/%s', "Suggest a better explanation for "), 'python-suggest-improve': - ("https://github.com/uthcode/learntosolveit/edit/version1/languages/python/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/languages/python/%s", "Suggest a Code Improvement:"), 'python-better-explain': - ("https://github.com/uthcode/learntosolveit/edit/version1/source/python/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/source/python/%s", "Suggest a better explanation for "), 'ruby-suggest-improve': - ("https://github.com/uthcode/learntosolveit/edit/version1/languages/ruby/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/languages/ruby/%s", "Suggest a Code Improvement:"), 'ruby-better-explain': - ("https://github.com/uthcode/learntosolveit/edit/version1/source/ruby/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/source/ruby/%s", "Suggest a better explanation for "), 'java-suggest-improve': - ("https://github.com/uthcode/learntosolveit/edit/version1/languages/java/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/languages/java/%s", "Suggest a Code Improvement:"), 'java-better-explain': - ("https://github.com/uthcode/learntosolveit/edit/version1/source/java/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/source/java/%s", "Suggest a better explanation for "), 'scala-suggest-improve': - ("https://github.com/uthcode/learntosolveit/edit/version1/languages/scala/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/languages/scala/%s", "Suggest a Code Improvement:"), 'scala-better-explain': - ("https://github.com/uthcode/learntsolveit/edit/version1/source/scala/%s", + ("https://github.com/uthcode/learntsolveit/edit/master/source/scala/%s", "Suggest a better explanation for "), 'go-suggest-improve': - ("https://github.com/uthcode/learntosolveit/edit/version1/languages/go/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/languages/go/%s", "Suggest a Code Improvement:"), 'go-better-explain': - ("https://github.com/uthcode/learntosolveit/edit/version1/source/go/%s", + ("https://github.com/uthcode/learntosolveit/edit/master/source/go/%s", "Suggest a better explanation for "), 'use-local-compiler': ('http://www.seas.upenn.edu/cets/answers/%s.html', From f2d44dc523abb6b8b326e8d19137fd9e52c06de1 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 07:52:39 -0700 Subject: [PATCH 003/272] Updated requirements. --- .readthedocs.yml | 24 ++++++++++++++++++++++++ languages/cprogs/makedir.c | 6 +++--- source/conf.py | 2 ++ source/cprogramming/makedir.rst | 2 -- source/requirements.txt | 1 + 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .readthedocs.yml create mode 100644 source/requirements.txt diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 00000000..bd11b21e --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,24 @@ +# .readthedocs.yml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: source/conf.py + +# Build documentation with MkDocs +#mkdocs: +# configuration: mkdocs.yml + +# Optionally build your docs in additional formats such as PDF and ePub +formats: all + +# Optionally set the version of Python and requirements required to build your docs +python: + version: 3.7 + install: + - requirements: docs/requirements.txt + diff --git a/languages/cprogs/makedir.c b/languages/cprogs/makedir.c index d4359951..4ddb9b39 100644 --- a/languages/cprogs/makedir.c +++ b/languages/cprogs/makedir.c @@ -1,7 +1,7 @@ -#include -#include +#include +#include + int main(int argc, char *argv[]) { mkdir("foobar",'644'); } - diff --git a/source/conf.py b/source/conf.py index 42c769fb..3cd6edb4 100644 --- a/source/conf.py +++ b/source/conf.py @@ -45,6 +45,8 @@ # 'sphinx.ext.extlinks', 'sphinx.ext.pngmath', # 'sphinxcontrib.runcode'] +extensions = ['sphinx.ext.extlinks'] + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/source/cprogramming/makedir.rst b/source/cprogramming/makedir.rst index 2633f553..601e02cb 100644 --- a/source/cprogramming/makedir.rst +++ b/source/cprogramming/makedir.rst @@ -5,11 +5,9 @@ makedir *makedir.c* .. literalinclude:: ../../languages/cprogs/makedir.c - :language: c :tab-width: 4 - .. seealso:: * :c-suggest-improve:`makedir.c` diff --git a/source/requirements.txt b/source/requirements.txt new file mode 100644 index 00000000..59aa86cc --- /dev/null +++ b/source/requirements.txt @@ -0,0 +1 @@ +sphinx_bootstrap_theme From a9b92d2e4dae0cd0b70485473c1dca33b142593f Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 07:55:36 -0700 Subject: [PATCH 004/272] Fix the requirements file. --- .readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index bd11b21e..e7098765 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -20,5 +20,5 @@ formats: all python: version: 3.7 install: - - requirements: docs/requirements.txt + - requirements: source/requirements.txt From b8a2e268b4064cbdcab7bb53b40444efa303aaa4 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 08:07:33 -0700 Subject: [PATCH 005/272] Update index.rst --- source/index.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/index.rst b/source/index.rst index 0cde9334..5b8d0ca0 100644 --- a/source/index.rst +++ b/source/index.rst @@ -1,19 +1,19 @@ -Tools to Learn, Understand and Solve Problems -============================================= +Learn, Understand and Solve Problems +==================================== -The idea behind learn to solve it website is to present content that will help you to learn programming languages, -technical content and tools that that will help you learn the subject that you wish to learn. +This website contains example snippets and explainations. The idea is learn, +understand and solve problems. These small pieces are often the building blocks +for larger solutions. -This has mostly computer science technical content as of now. It has example snippets from programming languages to -play with, has solutions to interesting problems presented books that can be helpful to understand the concepts. It -has explainations for difficult algorithms, has common interview problems. +The problems are taken from well known sources, exercises in books. -It has notes from various massive online courses in the web. It has notes for Georgia tech's OMSCS program. It has -notes from various papers. It is a repository for the content that Senthil wrote mosty for himself and for others. +The copyright of those problems belongs to author of the books. -The general idea is to explore, play with concepts as we learn something new. +The solutions are either written by me or copied from other places. If they are +copied, I attribute the reference. If it is missing, I apologize, and I will +remove it. The explaination are written by contributors. -There are countless websites like this in the web. Those will be referenced here. +The general idea is to explore, play with concepts as I learn something new. Programming Languages From 23c90e81db76c3f5113417d458ddb81db317b000 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 08:09:03 -0700 Subject: [PATCH 006/272] Updated copyright. --- source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/conf.py b/source/conf.py index 3cd6edb4..f5a3a631 100644 --- a/source/conf.py +++ b/source/conf.py @@ -61,7 +61,7 @@ # General information about the project. project = u'Learn To Solve It' -copyright = u'2016, Senthil Kumaran' +copyright = u'2020, Senthil Kumaran' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the From 45ba86fba9241078b885f418dd2d875e3ce0aa39 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 08:20:52 -0700 Subject: [PATCH 007/272] Updated source index. --- .readthedocs.yml | 2 +- source/index.rst | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index e7098765..b843136e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -14,7 +14,7 @@ sphinx: # configuration: mkdocs.yml # Optionally build your docs in additional formats such as PDF and ePub -formats: all +formats: [] # Optionally set the version of Python and requirements required to build your docs python: diff --git a/source/index.rst b/source/index.rst index 5b8d0ca0..7c417bc9 100644 --- a/source/index.rst +++ b/source/index.rst @@ -1,20 +1,17 @@ Learn, Understand and Solve Problems ==================================== -This website contains example snippets and explainations. The idea is learn, -understand and solve problems. These small pieces are often the building blocks -for larger solutions. +This website contains example of snippets and explainations. The idea is to +learn, understand and solve problems. These small pieces are often the building +blocks of larger solutions. -The problems are taken from well known sources, exercises in books. - -The copyright of those problems belongs to author of the books. - -The solutions are either written by me or copied from other places. If they are -copied, I attribute the reference. If it is missing, I apologize, and I will -remove it. The explaination are written by contributors. - -The general idea is to explore, play with concepts as I learn something new. +The problems are taken from well known sources, exercises in books. The +copyright of those problems belongs to author of the books. +The solutions are either written by me, contributors or copied from other +places. If they are copied, I attribute with reference. If it is missing, I +apologize, and I will correct it. The explaination are written by me and other +contributors. Programming Languages --------------------- From 7d19bc36b16f0abae74d3e4f0f30cb40cda3116c Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 08:31:44 -0700 Subject: [PATCH 008/272] Update with directives used. --- README.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 2282d548..485e85c0 100644 --- a/README.rst +++ b/README.rst @@ -4,6 +4,11 @@ learntosolveit This is the main site with all the source code snippets and documentation. +.. image:: https://readthedocs.org/projects/learntosolveit/badge/?version=latest + :target: https://www.learntosolveit.com/?badge=latest + :alt: Documentation Status + + directives used --------------- @@ -17,6 +22,8 @@ For the Run This link. For the suggest-improve and better-explain C programming contents +:: + :c-suggest-improve:`filename.c` :c-better-explain:`filename.rst` @@ -28,7 +35,6 @@ Dependencies * https://github.com/uthcode/sphinxcontrib-runcode/ * https://github.com/ryan-roemer/sphinx-bootstrap-theme - Contact ------- From bad6277fd4f5e9e6c2d22219bd42ed298b7a9870 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 08:33:13 -0700 Subject: [PATCH 009/272] Added correct link to the documentation. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 485e85c0..3087326e 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ -learntosolveit -============== +https://www.learntosolveit.com +============================== This is the main site with all the source code snippets and documentation. From 305cdc6499f5df6fab8ff284cd93c2a8e4843c49 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 15:36:05 -0700 Subject: [PATCH 010/272] Embedding it Python tutor. --- source/cprogramming/sec_1.1_helloworld.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/cprogramming/sec_1.1_helloworld.rst b/source/cprogramming/sec_1.1_helloworld.rst index 5b78895e..05985435 100644 --- a/source/cprogramming/sec_1.1_helloworld.rst +++ b/source/cprogramming/sec_1.1_helloworld.rst @@ -21,10 +21,13 @@ Solution :language: c :tab-width: 4 -.. runcode:: ../../languages/cprogs/sec_1.1_helloworld.c - :language: c - :codesite: ideone +Understand +---------- + +.. raw:: html + + .. seealso:: From a2c52c93448d7dcfe8399e8d90e996a3ab3acdde Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 16:12:09 -0700 Subject: [PATCH 011/272] Visualize Python tutor execution. --- source/cprogramming/sec_1.2_fahr2cel.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/cprogramming/sec_1.2_fahr2cel.rst b/source/cprogramming/sec_1.2_fahr2cel.rst index 12a78405..adffe26e 100644 --- a/source/cprogramming/sec_1.2_fahr2cel.rst +++ b/source/cprogramming/sec_1.2_fahr2cel.rst @@ -38,6 +38,13 @@ fahr <= upper is true if it is true then it assigns the variable celsius 5 * (fahr - 32) / 9 and then it prints out put. +Understand +---------- + +.. raw:: html + + + .. seealso:: From b07ef8fd96563503e42cfd5182c0da6cacd7243c Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 16:22:24 -0700 Subject: [PATCH 012/272] Correct Runcode Directive. --- source/cprogramming/sec_1.2_fahr2cel.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/cprogramming/sec_1.2_fahr2cel.rst b/source/cprogramming/sec_1.2_fahr2cel.rst index adffe26e..b9159913 100644 --- a/source/cprogramming/sec_1.2_fahr2cel.rst +++ b/source/cprogramming/sec_1.2_fahr2cel.rst @@ -18,10 +18,6 @@ Program :tab-width: 4 -.. runcode:: ../../languages/cprogs/sec_1.2_fahr2cel.c - :language: c - :codesite: ideone - Explanation =========== From 4b5577e9fc737d191db1a57c4d8bd65a68488c27 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 16:25:22 -0700 Subject: [PATCH 013/272] http based tutor. --- source/cprogramming/sec_1.2_fahr2cel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/cprogramming/sec_1.2_fahr2cel.rst b/source/cprogramming/sec_1.2_fahr2cel.rst index b9159913..4afcb322 100644 --- a/source/cprogramming/sec_1.2_fahr2cel.rst +++ b/source/cprogramming/sec_1.2_fahr2cel.rst @@ -39,7 +39,7 @@ Understand .. raw:: html - + .. seealso:: From f89ac6e65cc9c1a20b4e8269fdccfd8268a89bea Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Sun, 19 Apr 2020 21:00:49 -0700 Subject: [PATCH 014/272] update requirements txt --- source/requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/requirements.txt b/source/requirements.txt index 59aa86cc..818fcc1e 100644 --- a/source/requirements.txt +++ b/source/requirements.txt @@ -1 +1,3 @@ sphinx_bootstrap_theme +https://dl.dropbox.com/s/u66xbjsfi1o7yw7/sphinxcontrib-runcode-0.2.1.tar.gz + From 3237b0558839847c4dce31318c84916640913492 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 20 Apr 2020 04:14:42 -0700 Subject: [PATCH 015/272] revert the installation of runcode. --- source/requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/requirements.txt b/source/requirements.txt index 818fcc1e..59aa86cc 100644 --- a/source/requirements.txt +++ b/source/requirements.txt @@ -1,3 +1 @@ sphinx_bootstrap_theme -https://dl.dropbox.com/s/u66xbjsfi1o7yw7/sphinxcontrib-runcode-0.2.1.tar.gz - From e39eb071509d68ee3aecca02b293f1adb092dbc2 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 20 Apr 2020 04:42:46 -0700 Subject: [PATCH 016/272] Update the section on Fahr 2 Cel. --- source/cprogramming/sec_1.2_fahr2cel.rst | 2 +- source/python/algorithm_hanoi.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/cprogramming/sec_1.2_fahr2cel.rst b/source/cprogramming/sec_1.2_fahr2cel.rst index 4afcb322..fcd09a0c 100644 --- a/source/cprogramming/sec_1.2_fahr2cel.rst +++ b/source/cprogramming/sec_1.2_fahr2cel.rst @@ -39,7 +39,7 @@ Understand .. raw:: html - + .. seealso:: diff --git a/source/python/algorithm_hanoi.rst b/source/python/algorithm_hanoi.rst index ee519df8..74b0de52 100644 --- a/source/python/algorithm_hanoi.rst +++ b/source/python/algorithm_hanoi.rst @@ -29,7 +29,7 @@ Visualize .. raw:: html - + Explanation @@ -40,4 +40,4 @@ Explanation .. seealso:: * :python-suggest-improve:`algorithm_hanoi.py` - * :python-better-explain:`algorithm_hanoi.rst` \ No newline at end of file + * :python-better-explain:`algorithm_hanoi.rst` From a8f4ce4e1c6c95050f8aee7f860af8743ed270a9 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 20 Apr 2020 06:33:28 -0700 Subject: [PATCH 017/272] Update Documents. --- source/cprogramming/sec_1.1_helloworld.rst | 2 +- source/cprogramming/sec_1.2_fahr2cel.rst | 2 +- source/python/algorithm_hanoi.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/cprogramming/sec_1.1_helloworld.rst b/source/cprogramming/sec_1.1_helloworld.rst index 05985435..be56b011 100644 --- a/source/cprogramming/sec_1.1_helloworld.rst +++ b/source/cprogramming/sec_1.1_helloworld.rst @@ -27,7 +27,7 @@ Understand .. raw:: html - + .. seealso:: diff --git a/source/cprogramming/sec_1.2_fahr2cel.rst b/source/cprogramming/sec_1.2_fahr2cel.rst index fcd09a0c..5972d487 100644 --- a/source/cprogramming/sec_1.2_fahr2cel.rst +++ b/source/cprogramming/sec_1.2_fahr2cel.rst @@ -39,7 +39,7 @@ Understand .. raw:: html - + .. seealso:: diff --git a/source/python/algorithm_hanoi.rst b/source/python/algorithm_hanoi.rst index 74b0de52..b2eb191d 100644 --- a/source/python/algorithm_hanoi.rst +++ b/source/python/algorithm_hanoi.rst @@ -29,7 +29,7 @@ Visualize .. raw:: html - + Explanation From 1b15a136de05342aea087ad0f27ce78594e9d9d6 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Mon, 20 Apr 2020 07:21:31 -0700 Subject: [PATCH 018/272] Updated formatting. --- source/_templates/index.html | 2 +- source/_templates/layout.html | 19 +------------------ source/_templates/logo.html | 2 +- source/cprogramming/sec_1.1_helloworld.rst | 2 +- source/cprogramming/sec_1.2_fahr2cel.rst | 4 +++- source/python/algorithm_hanoi.rst | 15 ++++++--------- 6 files changed, 13 insertions(+), 31 deletions(-) diff --git a/source/_templates/index.html b/source/_templates/index.html index bd246496..4211fe67 100644 --- a/source/_templates/index.html +++ b/source/_templates/index.html @@ -1,4 +1,4 @@ {# {% extends "layout.html" %} #} -{% set title = 'Uthcode' %} +{% set title = 'LearnToSolveIt' %} {% block body %} {% endblock %} diff --git a/source/_templates/layout.html b/source/_templates/layout.html index 81cb1ab8..82a3aa35 100644 --- a/source/_templates/layout.html +++ b/source/_templates/layout.html @@ -2,30 +2,13 @@ {% block content %} {{ super() }} -
-
-
-
- - - Comments by Disqus -
-
-
{% endblock %} {%- block footer %} {{ super() }}