Skip to content

Instantly share code, notes, and snippets.

View yunchih's full-sized avatar

Yunchih Chen yunchih

  • NTU CSIE WSLAB
  • Taipei , Taiwan
View GitHub Profile
def heightBalanced[ U >: T <% Ordered[U] ]:Tree[U] = {
val lh = left.height
val rh = right.height
if( math.abs(lh-rh)<=1 ) this
else if(rh>lh) left append right addValue value
else right append left addValue value
}
/*
tree.scala:25: error: type mismatch;
found : Node[T(in class Node)]
//It is often useful to mark the request parameter as implicit so it can be implicitly used by other APIs that need it
Action { implicit request =>
Ok("Got request [" + request + "]")
}
// Q1: "it can be implicitly used by other APIs" --> Any examples?
// Q2: If the parameter of a method is marked "implicit", client needn't
// provide such parameter since the compiler will find it themselves, right?
// But I'm not able to apply this rule to the above example.
// What if Action is called without any parameter, i.e. " Action() "?
<?php
$A = array();
$B = array();
$C = array();
echo 'Array A :<br/>';
for($i=0;$i<10;$i++){
$random = rand(1,30);
array_push($A, $random);
echo $random . " ";
}
<?php
$ok = false; //sign up 尚未成功
if(isset($_POST['email'])):
$email = $_POST['email']; // 從 post 中取出 email
$password = $_POST['password']; // 從 post 中取出 password
$confirmPassword = $_POST['confirmPassword']; // 從 post 中取出 confirmPassword
/*
* 任務:
* 確認 password 和 confirmPassword 是否相同
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
/*
* Turn off notice so that empty array
* like $value and $error
* won't be taken as undefined array.
*/
?>
<!DOCTYPE HTML>
<html>
<!DOCTYPE HTML>
<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>
<?php
<?php
function convertToJSON($content){
$json = "[";
$row = explode("\n", $content);
$columnName = explode(",", $row[0]);
$len = count($row)-1;
$columnLen = count($columnName);
for ($i=0; $i < $columnLen; $i++) {
$columnName[$i] = trim($columnName[$i]);
}

###Problem 1

Here's an excerpt from a model class in Play.

SQL("update entry set title={title}, content={content}, date={date} where id = {id}").on(
        'title -> entry.title,
        'content -> entry.content,
        'date -> entry.date,
 'id -&gt; entry.id

You remember, of course, what joy you felt when you laid aside the garments of boyhood and donned the man's toga, and were escorted to the forum; nevertheless, you may look for a still greater joy when you have laid aside the mind of boyhood and when wisdom has enrolled you among men. For it is not boyhood that still stays with us, but something worse, – boyishness. And this condition is all the more serious because we possess the authority of old age, together with the follies of boyhood, yea, even the follies of infancy. Boys fear trifles, children fear shadows, we fear both.

--From Seneca's letters to Lucilius, letter 4--


###What does "boys fear trifles" mean?

/* Problem statement at https://github.com/pangfengliu/programmingtasks/issues/270 */
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
#include<assert.h>
#define MAX_VAR_LEN 8
#define MAX_VAR_NUM 100
#define MAX_LINE_NUM 1000
#define MAX_LINE_TOKENS 6