Instantly convert code snippets from Rust to Haskell with our free online code converter. Transform your code easily and accurately.
Experience the full potential of AI-driven code conversion and transformation!
We prioritize your code's security and privacy. Your code is not stored on our servers and is only temporarily processed for conversion. We use OpenAI's secure servers for the conversion process, ensuring your code remains confidential.
Rust is a multi-paradigm programming language focused on performance and safety, especially safe concurrency.
Haskell is a purely functional programming language.
fn is_palindrome(s: &str) -> bool {
let clean: String = s.chars()
.filter(|c| c.is_alphanumeric())
.map(|c| c.to_ascii_lowercase())
.collect();
clean.chars().eq(clean.chars().rev())
}
fn main() {
println!("{}", is_palindrome("A man, a plan, a canal: Panama")); // true
println!("{}", is_palindrome("race a car")); // false
}
import Data.Char (isAlphaNum, toLower)
isPalindrome :: String -> Bool
isPalindrome str = clean == reverse clean
where clean = map toLower $ filter isAlphaNum str
main :: IO ()
main = do
print $ isPalindrome "A man, a plan, a canal: Panama" -- True
print $ isPalindrome "race a car" -- False
fn bubble_sort(arr: &mut [i32]) {
let n = arr.len();
for i in 0..n {
for j in 0..n - i - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j + 1);
}
}
}
}
fn main() {
let mut arr = vec![64, 34, 25, 12, 22, 11, 90];
bubble_sort(&mut arr);
println!("{:?}", arr);
}
bubbleSort :: Ord a => [a] -> [a]
bubbleSort xs = foldr (\_ -> bubble) xs [1..length xs - 1]
where
bubble [] = []
bubble [x] = [x]
bubble (x:y:xs)
| x > y = y : bubble (x:xs)
| otherwise = x : bubble (y:xs)
main :: IO ()
main = print $ bubbleSort [64, 34, 25, 12, 22, 11, 90]
Convert Rust to Python
Open ConverterConvert Rust to JavaScript
Open ConverterConvert Rust to TypeScript
Open ConverterConvert Rust to Java
Open ConverterConvert Rust to C
Open ConverterConvert Rust to C++
Open ConverterConvert Rust to C#
Open ConverterConvert Rust to Go
Open ConverterConvert Rust to Dart
Open ConverterConvert Rust to Ruby
Open ConverterConvert Rust to Swift
Open ConverterConvert Rust to Kotlin
Open ConverterConvert Rust to Scala
Open ConverterConvert Rust to PHP
Open ConverterConvert Rust to R
Open ConverterConvert Rust to Julia
Open ConverterConvert Rust to MATLAB
Open ConverterConvert Rust to Lua
Open ConverterConvert Rust to Assembly
Open ConverterConvert Rust to Perl
Open ConverterConvert Rust to Groovy
Open ConverterConvert Rust to Elixir
Open ConverterConvert Rust to F#
Open ConverterConvert Rust to Clojure
Open ConverterConvert Rust to Delphi
Open Converter