(from Problem4 in https://web.stanford.edu/class/archive/cs/cs107/cs107.1186/exams/f1.pdf)
The below C code:
#include <stdlib.h>
int pinky(char *param1, int *param2) {
char *str = NULL;
int local = strtol(param1, &str, 0x10);
#include <stdbool.h> | |
#include <curses.h> | |
#include <locale.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <time.h> | |
#include <unistd.h> | |
#define STAGE_ROW 20 |
(from Problem4 in https://web.stanford.edu/class/archive/cs/cs107/cs107.1186/exams/f1.pdf)
The below C code:
#include <stdlib.h>
int pinky(char *param1, int *param2) {
char *str = NULL;
int local = strtol(param1, &str, 0x10);
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
#include <netinet/ip_icmp.h> | |
#include <arpa/inet.h> | |
#define SEND_BUF_LEN 64 |
#include <stdio.h> | |
#include <stdlib.h> | |
static char buf[30000]; | |
static char input[30000]; | |
static int idx = 0; | |
static char *ptr = buf; | |
void interpreter(int start); |
(for { | |
conn <- withConnection | |
currentIssue <- findIssueById(editReq.id)(conn) | |
_ <- isIssueEditable(currentIssue)(BadRequest) | |
_ <- updateIssue(editReq.id, editReq.content) | |
} yield Ok("ok")).run(Future.successful) |
package example | |
trait HashPerformance { | |
def hash(str: String): String | |
def doCheck(count: Int): Unit = { | |
val key = "something" | |
val hashed = hash(key) | |
println(hashed) |
package com.tiqwab.example.step4 | |
import scala.collection.mutable.ListBuffer | |
import scala.collection.{immutable, mutable, SeqFactory, StrictOptimizedLinearSeqOps} | |
class MyList[+A] private (elems: List[A]) | |
extends immutable.LinearSeq[A] with immutable.LinearSeqOps[A, MyList, MyList[A]] | |
with StrictOptimizedLinearSeqOps[A, MyList, MyList[A]] { | |
// To be overridden in implementations, as said in scala.collection.LinearSeq | |
override def isEmpty: Boolean = elems.isEmpty |
package com.tiqwab.example.step6 | |
import scala.collection.JavaConverters._ | |
import scala.collection.immutable | |
trait MyBuilder[-Elem, +To] { | |
def +=(elem: Elem): this.type | |
def result(): To | |
} |
package sample | |
import java.io.{BufferedReader, InputStreamReader} | |
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials} | |
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration | |
import com.amazonaws.services.s3.{AmazonS3, AmazonS3ClientBuilder} | |
import sample.FilePath | |
import org.scalatest._ |