Skip to main content
deleted 4 characters in body
Source Link
user92069
user92069

Use the ending conditions

Suppose you have a function taking an emptyreversing a list:

r([H|T])->[T]++r(H);r([])->[].

Since this is the only condition left, this can be golfed into:

r([H|T])->r(T)++[H];r(_)->[].

Or, since this is an identity function:

r([H|T])->r(T)++[H];r(I)->I.

You can also abuse the wild-cards in if statements. E.g.

if A<B->A;true->B end.

This can be golfed into:

if A<B->A;_->B end.

Use the ending conditions

Suppose you have a function taking an empty list:

r([H|T])->[T]++r(H);r([])->[].

Since this is the only condition left, this can be golfed into:

r([H|T])->r(T)++[H];r(_)->[].

Or, since this is an identity function:

r([H|T])->r(T)++[H];r(I)->I.

You can also abuse the wild-cards in if statements. E.g.

if A<B->A;true->B end.

This can be golfed into:

if A<B->A;_->B end.

Use the ending conditions

Suppose you have a function reversing a list:

r([H|T])->[T]++r(H);r([])->[].

Since this is the only condition left, this can be golfed into:

r([H|T])->r(T)++[H];r(_)->[].

Or, since this is an identity function:

r([H|T])->r(T)++[H];r(I)->I.

You can also abuse the wild-cards in if statements. E.g.

if A<B->A;true->B end.

This can be golfed into:

if A<B->A;_->B end.
Source Link
user92069
user92069

Use the ending conditions

Suppose you have a function taking an empty list:

r([H|T])->[T]++r(H);r([])->[].

Since this is the only condition left, this can be golfed into:

r([H|T])->r(T)++[H];r(_)->[].

Or, since this is an identity function:

r([H|T])->r(T)++[H];r(I)->I.

You can also abuse the wild-cards in if statements. E.g.

if A<B->A;true->B end.

This can be golfed into:

if A<B->A;_->B end.