以下问题必答。
- 请优化这段代码,提高可读性
- 请给出这段代码的运行结果,并解释为什么
- 请实现下段代码 JavaScript版 | TypeScript版
function testClosures() { | |
"use strict"; | |
var result = []; | |
for (var var_index = 0; var_index < 2; var_index++) { | |
result.push(() => { return var_index; }); | |
} | |
for (let let_index = 0; let_index < 2; let_index++) { | |
result.push(() => { return let_index; }); | |
} |
"use strict"; | |
function next (str) { | |
const charArr = str.split(''); | |
const charReverseArr = charArr.reverse(); | |
const inflectionIndex = charReverseArr.findIndex((element, index, array) => element < array[index - 1]); | |
const right = charReverseArr.slice(0, inflectionIndex); |
/** | |
* 多项式相乘 [多项式1, 多项式2, 多项式3...] | |
* 多项式 {次数1: 系数1, 次数2: 系数2, ...} | |
*/ | |
var simplePolynomials = [ | |
{ | |
0: 1, | |
1: 1, | |
2: 1, | |
3: 1, |
#lang scheme | |
(define (square x) (* x x)) | |
(define (gcd a b) | |
(if (= 0 b) | |
a | |
(gcd b (remainder a b)))) | |
(define (expmod base exp m) | |
(cond ((= exp 0) 1) |
#lang scheme | |
(define (average . numbers) | |
(/ (apply + numbers) (length numbers))) | |
(define tolerance 0.000001) | |
(define (fixed-point f first-guess) | |
(define (close-enough? v1 v2) | |
(< (abs (- v1 v2)) tolerance)) | |
(define (try guess) |
#lang racket | |
(define variable? symbol?) | |
(define (same-variable? v1 v2) | |
(and (variable? v1) (variable? v2) (eq? v1 v2))) | |
(define (=number? exp num) | |
(and (number? exp) (= exp num))) |
以下问题必答。
I hereby claim:
To claim this, I am signing this object:
λ curl -X POST \ | |
http://chouun.nadileaf.com/api/open-candidates/ \ | |
-H 'authorization: Bearer <TOKEN>' \ | |
-H 'cache-control: no-cache' \ | |
-H 'content-type: application/json' \ | |
-H 'postman-token: 1c12fc65-c157-49c7-d9d4-d2ad10832c53' \ | |
-d ' | |
{ | |
"openid": "b39fe420-d67e-11e7-a5de-0250bbe96648", | |
"industry":"互联网", |
// utils | |
class FromJsonQueryStringBindable[T] ()(implicit decoder: Decoder[T], | |
encoder: Encoder[T]) extends QueryStringBindable[T] { | |
implicit val binder: QueryStringBindable[Json] = JsonQueryStringBindable | |
override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, T]] = | |
binder.bind(key, params).map(_.flatMap(_.as[T].left.map(_.message))) | |
override def unbind(key: String, value: T): String = s"$key=${value.asJson}" | |
} |