How to check if two strings are the same in Julia?

This recipe helps you to check if two strings are the same in Julia.

Recipe Objective: How to check if two strings are the same in Julia?

This recipe explains how to check if the strings are the same in Julia.
For more related projects-
Project 1
Project 2

Learn How to use XLNet for Text Classification

cmp() Method

Julia provides cmp() is an inbuilt function to compare two strings in Julia.
Its syntax is cmp(str1::AbstractString, str2::AbstractString)
where its parameters are first string and second string to be compared. It returns 0 if both passed strings are having the same length and the character at each index is the same in both strings, it returns -1 if str1 is a prefix of str2, or if str1 comes before str2 in alphabetical order and return 1 if str2 is a prefix of str1, or if str2 comes before str1 in alphabetical order.

println(cmp("julia", "julia"))
println(cmp("j", "J"))
println(cmp("u", "l"))
println(cmp("jl", "jul"))
println(cmp("jul", "ju"))
println(cmp("ju", "jl"))

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

MLOps Project on GCP using Kubeflow for Model Deployment
MLOps using Kubeflow on GCP - Build and deploy a deep learning model on Google Cloud Platform using Kubeflow pipelines in Python

NLP Project on LDA Topic Modelling Python using RACE Dataset
Use the RACE dataset to extract a dominant topic from each document and perform LDA topic modeling in python.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Deep Learning Project- Real-Time Fruit Detection using YOLOv4
In this deep learning project, you will learn to build an accurate, fast, and reliable real-time fruit detection system using the YOLOv4 object detection model for robotic harvesting platforms.

Build a Hybrid Recommender System in Python using LightFM
In this Recommender System project, you will build a hybrid recommender system in Python using LightFM .

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Build an Image Segmentation Model using Amazon SageMaker
In this Machine Learning Project, you will learn to implement the UNet Architecture and build an Image Segmentation Model using Amazon SageMaker

Build Time Series Models for Gaussian Processes in Python
Time Series Project - A hands-on approach to Gaussian Processes for Time Series Modelling in Python

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.