Search
 
SCRIPT & CODE EXAMPLE
 

RUST

reverse a string with runes

runes := []rune(s)
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
   runes[i], runes[j] = runes[j], runes[i]
}
t := string(runes)
Comment

reverse a string with runes

// Reverse a string with runes
fn main() {
    let r: String = "一二三四五六七八九十".chars().rev().collect();
    println!("original    {:?}", "一二三四五六七八九十");
    println!("reverse r = {:?}", "一二三四五六七八九十");    
    assert_eq!(r, "十九八七六五四三二一");
}
Comment

PREVIOUS NEXT
Code Example
Rust :: armanriazi•rust•error•already borrowed: BorrowMutError 
Rust :: rust•armanriazi•concept•nan 
Rust :: trait in rust 
Rust :: convert i32 to usize rust 
Lua :: print table lua 
Lua :: luau make a rainbow part 
Lua :: Get number of values in a table lua 
Lua :: how to get last element of array in lua 
Lua :: if part is touched 
Lua :: rgb to hex lua 
Lua :: roblox loop all players 
Lua :: roblox studio lua for loop 
Lua :: loop true childs roblox 
Lua :: roblox what is humanoid 
Lua :: how to get the length of a table in lua 
Lua :: roblox check if in private server 
Lua :: table.find lua 
Lua :: wait for player character roblox 
Lua :: How to Register a command in Lua 
Lua :: Get Nearest Player fivem 
Lua :: lua how to default value if nil or false 
Lua :: enable http service roblox 
Matlab :: matlab count elements in matrix 
Matlab :: matlab symbolic integration 
Matlab :: matlab app designer axes buttondownfcn 
Basic :: whats up 
Elixir :: elixir get_in 
Elixir :: elixir enum chunk_by 
Scala :: scala tutorial 
Actionscript :: dynamic computed property vue 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =