Skip to content

Commit

Permalink
Split out list operations
Browse files Browse the repository at this point in the history
  • Loading branch information
calaldees committed Oct 22, 2024
1 parent 9693299 commit ea57b97
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,17 @@ function define_list() {
if (cc.indexOf("z") >= 0) { // VER: define_list
console.log("z exists in list") // VER: define_list
} // VER: define_list
dd = ["d", "e"] // VER: define_list
ee = cc.concat(dd) // VER: define_list
JSON.stringify(ee) === JSON.stringify(["a","b","c","d","e"]) // VER: define_list
}

function list_operations() {
let cc = ["a", "b", "c"] // VER: list_operations
let dd = ["d", "e"] // VER: list_operations
ee = cc.concat(dd) // VER: list_operations
if (JSON.stringify(ee) === JSON.stringify(["a","b","c","d","e"])) { // VER: list_operations
console.log("the same") // VER: list_operations
} // VER: list_operations
dd.every((v,i)=> v === ee[i]) // faster than stringify - https://stackoverflow.com/a/42186143/3356840
// TODO: Slice // VER: list_operations
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,14 @@ def define_list():
print(i) # z d # VER: define_list
if "z" in cc: # VER: define_list
print("z exists in list") # VER: define_list
dd = ["d", "e"] # VER: define_list
ee = cc + dd # VER: define_list
ee == ["a","b","c","d","e"] # VER: define_list

def list_operations():
cc = ["a", "b", "c"] # VER: list_operations
dd = ["d", "e"] # VER: list_operations
ee = cc + dd # VER: list_operations
if ee == ["a","b","c","d","e"]: # VER: list_operations
print("The same") # VER: list_operations
# TODO: Slice # VER: list_operations


def define_2d_arrays():
Expand Down

0 comments on commit ea57b97

Please sign in to comment.