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
type SymbolSearchXml struct { | |
XMLName xml.Name `xml:"eSearchResult"` | |
Count int `xml:"Count"` | |
RetMax int `xml:"RetMax"` | |
RetStart int `xml:"RetStart"` | |
IdList []int `xml:"IdList>Id"` | |
TranslationSet string `xml:"TranslationSet"` | |
TranslationStack TranslationStackXml `xml:"TranslationStack"` | |
QueryTranslation string `xml:"QueryTranslation"` | |
} |
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
var mapResp map[string]interface{} | |
if err := json.NewDecoder(res.Body).Decode(&mapResp); err == nil { | |
// fmt.Println(`&mapResp:`, &mapResp, "\n") | |
// fmt.Println(`mapResp["hits"]:`, mapResp["hits"]) | |
for _, value := range mapResp["hits"].(map[string]interface{}) { | |
if reflect.TypeOf(value).Kind() != reflect.Float64 { | |
for _, each := range value.([]interface{}) { |
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
function quick_sort(list) | |
if length(list)<2 | |
return list | |
end | |
pivot = list[1] | |
greater = [] | |
lesser = [] | |
for i = 2:length(list) | |
if pivot <= list[i] | |
append!(greater,list[i]) |
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
k=0 | |
g=0 | |
t=0 | |
function binary_search(list,item,len_list) | |
global k | |
global g | |
global t | |
if list==[] | |
return 0 | |
end |
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
function find_maximum(array) | |
global maximum | |
if length(array)==0 | |
return maximum | |
end | |
if maximum<last(array) | |
maximum=last(array) | |
end | |
println(array) |
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
function get_length(array) | |
if array==[] | |
return 0 | |
end | |
deleteat!(array, last(array)) | |
return 1 + get_length(array) | |
end | |
println(get_length([1,2,3,4])) |
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
function sum(array) | |
k=length(array) | |
if k==0 | |
return 0 | |
end | |
if k==1 | |
return array[k] | |
end | |
return array[k] + sum(array[1:k-1]) | |
end |
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
function binary_search(list,item) | |
low = 0 | |
high = size(list)[1] | |
while low <= high | |
mid = (low + high) | |
guess = list[mid] | |
if guess == item | |
return mid | |
end | |
if guess > item |
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
#[path="models/cafef_liveboard.rs"] | |
pub mod cafef_liveboard; | |
use reqwest::header::CONTENT_TYPE; | |
use reqwest::header::USER_AGENT; | |
use regex::Regex; | |
use chrono::prelude::*; | |
use std::fs::File; | |
use std::io::{self, BufRead}; | |
use std::path::Path; | |
use crate::cafef_liveboard::*; |
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
extern crate reqwest; | |
extern crate tokio; | |
extern crate serde_json; | |
extern crate serde; | |
use serde::{Deserialize}; | |
#[derive(Deserialize, Debug)] |