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
import { findMatchingAndMoveToFirst } from "./findMatchingAndMoveToFirst" | |
interface Product{ | |
name: string | |
description: string | |
price: number | |
} | |
function compareProducts(self: Product, other: Product): boolean { | |
return self.name === other.name && self.description === other.description && self.price === other.price |
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
import { findMatchingAndMoveToFirst } from "./findMatchingAndMoveToFirst" | |
interface User { | |
firstName: string | |
lastName: string | |
} | |
function compareUsers(self: User, other: User): boolean { | |
return self.firstName === other.firstName && self.lastName === other.lastName | |
} |
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
export interface Compare<T, U> { | |
compare: (t: T, u: U) => boolean | |
} | |
export function findMatchingAndMoveToFirst<T, U extends Compare<T, U>>( | |
list: readonly T[], | |
shouldbeFirst: U | |
): T[] { | |
return list.reduce( | |
(accumulator: T[], current: T) => |
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
interface User { | |
firstName: string | |
lastName: string | |
} | |
function findMatchingAndMoveToFirst( | |
users: readonly User[], | |
shouldBeFirst: User | |
) { | |
return users.reduce( |
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
const users = [ | |
{ firstName: 'Jane', lastName: 'Foo' }, | |
{ firstName: 'John', lastName: 'Bar' }, | |
{ firstName: 'Jill', lastName: 'Err' } | |
] | |
function findMatchingAndMoveToFirst (users, shouldBeFirst) { | |
return users.reduce( | |
(accumulator, current) => | |
current.firstName === shouldBeFirst.firstName && |
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
const users = [ | |
{ firstName: 'Jane', lastName: 'Foo' }, | |
{ firstName: 'John', lastName: 'Bar' }, | |
{ firstName: 'Jill', lastName: 'Err' } | |
] | |
function findMatchingAndMoveToFirst (users, shouldBeFirst) { | |
return users.reduce((accumulator, current) => { | |
return current.firstName === shouldBeFirst.firstName && | |
current.lastName === shouldBeFirst.lastName |
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
const users = [ | |
{ firstName: 'Jane', lastName: 'Foo' }, | |
{ firstName: 'John', lastName: 'Bar' }, | |
{ firstName: 'Jill', lastName: 'Err' } | |
] | |
function findMatchingAndMoveToFirst (users, shouldBeFirst) { | |
return users.reduce((accumulator, current) => { | |
if ( | |
current.firstName === shouldBeFirst.firstName && |
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
const users = [ | |
{ firstName: 'Jane', lastName: 'Foo' }, | |
{ firstName: 'John', lastName: 'Bar' }, | |
{ firstName: 'Jill', lastName: 'Err' } | |
] | |
function findMatchingAndMoveToFirst (users, shouldBeFirst) { | |
const reArrangedUsers = [] | |
users.forEach(user => { |
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
const users = [ | |
{ firstName: 'Jane', lastName: 'Foo' }, | |
{ firstName: 'John', lastName: 'Bar' }, | |
{ firstName: 'Jill', lastName: 'Err' } | |
] | |
function findMatchingAndMoveToFirst (users, shouldBeFirst) { | |
users.forEach((user, index) => { | |
if ( | |
user.firstName === shouldBeFirst.firstName && |
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
import my.androidapp | |
import my.androidapp.models | |
suspend fun getSpaceX(limit:Int) { | |
val vLimit = "\$limit" | |
val query = """ | |
query($vLimit:Int) | |
{ | |
launchesPast(limit: $vLimit) { | |
mission_name |
NewerOlder