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
; find list length | |
(defun my-list-length (l) | |
(cond ((endp l) 0) | |
(t (1+ (MY-LENGTH (rest l)))) | |
)) |
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
(defun COUNT-SUBLISTS (l) | |
(cond | |
((endp l) 0) | |
((listp (first l)) | |
(+ 1 (COUNT-SUBLISTS (rest l)))) | |
(T (COUNT-SUBLISTS (rest l))) | |
)) |
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
;item -> item to remove, can be atom or list | |
;l -> list to remove from | |
(defun REMOVE-FIRST (item l) | |
(cond | |
((endp l) nil) ; end of list | |
((equal item (first l)) (rest l)) ; if find, return rest | |
(t (cons (first l) (REMOVE-FIRST item (rest l)))) ; cons head item and list | |
)) |
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
(defun my-all-occ-remove (item l) | |
(cond | |
((endp l) nil) | |
((equal item (first l)) (my-all-occ-remove item (rest l))) ; remove item | |
(t (cons (first l) (my-all-occ-remove item (rest l)))) | |
)) |
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
(defun replace-first (i1 i2 l) | |
(cond | |
((endp l) nil) ; end of list | |
((equal i1 (first l)) (cons i2 (rest l))) ; found. combine cells with cons | |
(t (cons (first l) (replace-first i1 i2 (rest l)))) ; recursive rest call | |
) | |
) |
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
(defun count-atoms (l) | |
(cond | |
((endp l) 0) | |
((symbolp (first l)) (1+ (count-atoms (rest l)))) ; found an atom | |
(t (count-atoms (rest l))) ; recursive call | |
)) |
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
#include <stdio.h> | |
// Best case : Omega(n) | |
// worst case : O(n^2) | |
// awerage : Theta(n^2) | |
void bubbleSort(int arr[],int size); | |
void swap(int arr[],int x,int y); | |
int main(){ |
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
// _ | |
// | | | |
// | |__ _ __ ___ ___ _ __ _ __ | |
// | '_ \| '_ ` _ \ / _ \ '_ \| '_ \ | |
// | | | | | | | | | __/ | | | | | | | |
// |_| |_|_| |_| |_|\___|_| |_|_| |_| | |
#include <iostream> | |
using namespace std; |
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
#include <stdlib.h> | |
#include <stdio.h> | |
int findEqualIndex(int arr[],int start,int end); | |
int main(){ | |
int arr[6]={-10,-5,-1,0,4,5}; | |
int arr2[5]={0,2,5,8,7}; | |
int res = findEqualIndex(arr,0,5); |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
OlderNewer