This file contains hidden or 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
| class Manipulate2d { | |
| CanvasElement _canvas; | |
| RenderingContext _gl; | |
| int _positionAttri, _translationAttri, _rotationAttri, _scaleAttri; | |
| Buffer _vertexBuffer, _translationBuffer, _rotationBuffer, _scaleBuffer, _indicesBuffer; | |
| UniformLocation _resolutionUniform; | |
| Manipulate2d(c) { | |
| _canvas = c; | |
| _gl = _canvas.getContext3d(preserveDrawingBuffer: true); |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Numerics; | |
| using System.Text; | |
| using System.Threading.Tasks; | |
| namespace mathexpression { | |
| interface Term { |
This file contains hidden or 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
| module M4 = | |
| type Result<'Success, 'Failure> = | |
| | Success of 'Success | |
| | Failure of 'Failure | |
| type Request = {Name: string; Password: string; NewName: string} | |
| let Process request = | |
| match request with | |
| | {Name = ""} -> Failure "Name must not be blank" |
This file contains hidden or 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
| 题目一: | |
| 给你一个数学表达式,字符串形式的,只有简单的+-*/操作符,你计算出这个数学表达式的结果 | |
| input> "10*2-(2+5)" | |
| output> 10 | |
| 题目二: | |
| 把上面的程序改成可以支持S表达式 | |
| input> (- (* 10 2) (+ 2 5)) | |
| output> 10 |
This file contains hidden or 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
| create a robot, it can handle commands as below; | |
| "L" -> turn left | |
| "R" -> turn right | |
| "M" -> forward | |
| "B" -> back | |
| place it on a 2D map(x*y), and pass commands "LLRRLLMMBRL" to this robot, then the robot will move to the target place | |
| example: |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace ConsoleApplication1 { | |
| class Test { |
This file contains hidden or 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
| module test | |
| open NUnit.Framework | |
| open FsUnit | |
| open System | |
| let min (a: int) (b: int) (c: int) = | |
| Math.Min(a, Math.Min(b, c)) |
This file contains hidden or 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
| let pick items weight = | |
| let rec pick based = | |
| function | |
| | [] -> None | |
| | (w, _) as h :: _ when weight <= w + based -> Some h | |
| | (w, _) :: t -> pick (based + w) t | |
| pick 0.0 items |
This file contains hidden or 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
| module mytest | |
| open System | |
| open NUnit.Framework | |
| let seq (l: int list) = | |
| let rec helper (acc: int list) (rest: int list) = | |
| match acc, rest with | |
| | [], a :: b -> helper [a] b | |
| | _, [] -> acc |
This file contains hidden or 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
| #include <iostream> | |
| // { 1 2 3 4 } | |
| // { 5 6 7 8 } | |
| // { 9 10 11 12 } | |
| // {13 14 15 16 } | |
| // | |
| // 4 | |
| // 3 8 | |
| // 2 7 12 |
OlderNewer