Skip to main content
OCP30pt1c1l1l43-X1z17's user avatar
OCP30pt1c1l1l43-X1z17's user avatar
OCP30pt1c1l1l43-X1z17's user avatar
OCP30pt1c1l1l43-X1z17
  • Member for 2 years, 3 months
  • Last seen more than 1 year ago
Stats
113
reputation
4k
reached
0
answers
2
questions
Communities
About

Just another stackoverflow account

The account with the account ID before me https://magento.stackexchange.com/users/104655/spyros-popos

copied the URL of this post the second it was posted on 21st of April 2020 at 12:18 https://stackoverflow.com/questions/61340835/jstl-core-formatnumber-type-percent/61341107#61341107

This is my best friend: https://stackoverflow.com/users/9925119/rugbr%c3%b8d

type User = { name: string, gender: 'male' | 'female' }
// Vote for gender equality!
type GenderFluidUser = {
    [K in keyof User]: User[K] extends 'male' | 'female' ? any : User[K]
}

#Love playing with types

Always keep your Promise

let x = Promise.resolve(5)
let y = Promise.resolve(0)

let safe_divisision = (x: Promise<number>) => (y: Promise<number>): Promise<number> => x.then(valueX =>
    y.then(valueY => {
        if (valueY == 0) {
            return Promise.reject(`Cannot divide by 0 : ${valueX}/${valueY}`)
        } 
        return Promise.resolve(valueX/valueY)
    })
)

safe_divisision(x)(y).then(result => alert(result)).catch(reason => alert(reason))

userID: 11.534.547 Wish this was the amount of money on my bank account

Users next to me:

  1. https://stackoverflow.com/users/11534548/
  2. https://stackoverflow.com/users/11534549/
  3. https://stackoverflow.com/users/11534550/
  4. https://stackoverflow.com/users/11534551/
  5. https://stackoverflow.com/users/11534552/

FUNCTIONAL PROGRAMMING FOR LIFE!!!!!!!!!!!

type Fun<a, b> = (_: a) => b


type Option<T> = {
    kind: 'some'
    v: T
} | {
    kind: 'none'
}

let Some = <a>(v: a): Option<a> => ({ kind: 'some', v: v })
let None = <a>(): Option<a> => ({kind: 'none'})

let map_Option = <a, b>(f: Fun<a, b>, option: Option<a>): Option<b> =>
    option.kind == 'some' ? Some(f(option.v)) : None()

let join_option = <a>(option_of_option: Option<Option<a>>): Option<a> => 
    option_of_option.kind == 'some' ? option_of_option.v : option_of_option

let bind_Option = <a, b>(option: Option<a>, q: Fun<a, Option<b>>): Option<b> => 
    join_option(map_Option(q, option))

let a = Some(5)
let b = Some(2)

let divide_options = (x: Option<number>) => (y: Option<number>): Option<number> => bind_Option(x, valueX => 
    bind_Option(y, valueY => {
        if (valueY == 0) {
            return None()
        }
        return Some(valueX/valueY)
    })
)

alert(divide_options(a)(b).kind)

CODE

program script that present more then print "Hello World"

Badges
This user doesn’t have any gold badges yet.
1
silver badge
5
bronze badges
Top tags
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
0
Score
1
Posts
50
Posts %
Top posts