Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIgherOrderFunctionBallクラスの実装 #60

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions h24s_25/src/ts/higherorderfunctionball.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import{BallTypeEnum} from './balltypes';
import {BallInterface, HigherOrderFunctionBallInterface, NumberBallInterface, FunctionBallInterface} from './ballInterface';

export class HigherOrderFunctionBall<
S1 extends BallInterface|null,
O1 extends BallInterface|null,
S2 extends BallInterface|null,
O2 extends BallInterface|null,
> extends HigherOrderFunctionBallInterface<S1,O1,S2,O2>{
symbol: string;
applied: number[];
private readonly funcVal: (f: FunctionBallInterface<S1, O1>) => {self: S2, other: O2};

constructor(func: (f: FunctionBallInterface<S1, O1>) => {self: S2, other: O2}, symbol: string, applied: number[]) {
super();
this.funcVal = func;
this.symbol = symbol;
this.applied = applied;
}
override func(f: FunctionBallInterface<S1, O1>): { self: S2, other: O2 } {
return this.funcVal(f);
}
ballType(): BallTypeEnum {
return BallTypeEnum.HIGHER_ORDER_FUNCTION;
}

label(): string{
let label: string = this.symbol;
this.applied.forEach(
function (value) {
label += ` ${value.toString}`
}
)
return label;
}
}
Loading