This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.BorderLayout; | |
import java.awt.Color; | |
import java.awt.Dimension; | |
import java.awt.Font; | |
import java.awt.FontMetrics; | |
import java.awt.Graphics; | |
import java.awt.Graphics2D; | |
import java.awt.RenderingHints; | |
import java.awt.event.MouseAdapter; | |
import java.awt.event.MouseEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# try-logging.py | |
# Leon Tabak | |
# l.tabak@ieee.org | |
# 11 August 2021 | |
''' | |
Copyright 2021 Leon Hannah Tabak | |
Permission is hereby granted, free of charge, to any person obtaining |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
I wrote this code to introduce my students | |
to some features of the Kotlin language. | |
Leon Tabak | |
22 September 2021 | |
*/ | |
enum class ClippingStatus { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color | |
import java.awt.Font | |
import java.awt.GridLayout | |
import java.awt.event.ActionListener | |
import java.awt.event.ActionEvent | |
import javax.swing.JButton | |
import javax.swing.JFrame | |
import javax.swing.JMenu | |
import javax.swing.JMenuBar | |
import javax.swing.JMenuItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println("Experiment with lambda functions.") | |
val doublePlusOne: (Int) -> Int = {x:Int-> 2 * x + 1} | |
println( doublePlusOne(3) ) | |
val data = (0..3).map( doublePlusOne ) | |
println( data::class.simpleName ) | |
println( data ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.math.ln | |
fun main() { | |
// a specified mean for an exponential | |
// distribution of random numbers | |
val specifiedMean = 3.0 | |
// create a random number generator | |
val rng = kotlin.random.Random(System.nanoTime()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Process( val x0:Double, val x1:Double ) | |
fun main() { | |
// create random number generator | |
val rng = kotlin.random.Random(System.nanoTime()) | |
val elementInitializer: (Int) -> Process = | |
{_:Int -> Process(rng.nextDouble(), rng.nextDouble())} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.random.Random | |
// Create a list of processes. | |
// Each process has 2 properties: | |
// * it knows how much time has elapsed | |
// between the time that the previous | |
// process entered the waiting line | |
// and the time it took its place | |
// at the end of the line | |
// * it knows the time at which it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.PrintWriter | |
import scala.io.Source | |
object Higher extends App { | |
println("Sputnik!") | |
// Here's an example of a closure. | |
// f is a function that returns a | |
// function to its caller | |
// the function g that it returns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.eonsahead | |
object HelloGoodbye extends App { | |
def greetingMaker (): () => String = { | |
// This is a function that returns a function | |
// to its caller. | |
// This function ("greetingMaker") has one local | |
// variable (named "arriving"). |
OlderNewer