l = [1, 2, 3, 4, 5, 6, 7]
result = [i for i in l if i < 5]
print(result)
This file contains hidden or 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
| describe("EventRecommender", () => { | |
| const EventRecommender = require('../app/EventRecommender'); | |
| let er; | |
| beforeEach(() => { | |
| er = new EventRecommender(); | |
| }); | |
| describe("addEvent", () => { | |
| it("adds a new Event to the system", () => { |
This file contains hidden or 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 React, { Fragment } from 'react'; | |
| import PropTypes from 'prop-types'; | |
| import classnames from 'classnames'; | |
| import Link from '@tamm/ui-lib-link'; | |
| import Icon from '@tamm/ui-lib-icon'; | |
| import FeedbackModal from '@tamm/ui-lib-feedback-modal'; | |
| import nop from '@tamm/ui-lib-utils/nop'; | |
| import './Feedback.less'; | |
| import { STEP } from '@tamm/ui-lib-feedback-modal/FeedbackModal.const'; |
This file contains hidden or 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
| /* | |
| '(', '{', '[' are called "openers". | |
| ')', '}', ']' are called "closers". | |
| Write an efficient function that tells us whether input string's openers | |
| and closers are properly nested. | |
| Examples: | |
| "{ [ ] ( ) }" -> true | |
| "{ [ ( ] ) }" -> false |
This file contains hidden or 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
| <loading-container [loadable]="news$ | async"> | |
| <p *ngFor="let item of (news$ | async).entities">{{item}}</p> | |
| </loading-container> |
This file contains hidden or 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
| @Component({ | |
| selector: 'loading-container', | |
| template: ` | |
| <div *ngIf="loadable.loading">This is loading spinner...</div> | |
| <div *ngIf="loadable.error">{{loadable?.error?.message || 'Something went wrong'}}</div> | |
| <ng-container *ngIf="loadable.success"> | |
| <ng-content></ng-content> | |
| </ng-container> | |
| ` | |
| }) |
This file contains hidden or 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
| // базовый редуктор должен обновлять только не loadable состояния | |
| function baseNewsReducer(state: News = createDefaultNews(), action: NewsActions): News { | |
| switch (action.type) { | |
| case NewsActionsTypes.LoadSuccess: | |
| return { | |
| ...state, | |
| entities: action.payload.entities | |
| }; | |
| default: | |
| return state; |
This file contains hidden or 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 function withLoadable(baseReducer, {loadingActionType, successActionType, errorActionType}) { | |
| return (state, action) => { | |
| if (action.type === loadingActionType) { | |
| state = onLoadableLoad(state); | |
| } | |
| if (action.type === successActionType) { | |
| state = onLoadableSuccess(state); | |
| } | |
| if (action.type === errorActionType) { | |
| state = onLoadableError(state, action.error); |
This file contains hidden or 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
| @Component({ | |
| selector: 'app-news', | |
| template: ` | |
| <button (click)="load()">Load News</button> | |
| <!--loading spinner--> | |
| <p *ngIf="(news$ | async).loading">loading...</p> | |
| <p *ngFor="let item of (news$ | async).entities">{{item}}</p> | |
| ` | |
| }) |
This file contains hidden or 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
| @Effect() | |
| loadNews = this.actions$.pipe( | |
| ofType(NewsActionsTypes.Load), | |
| switchMap(action => { | |
| return this.http.get('some url').pipe( | |
| map((response: any) => new LoadNewsSuccess({entities: response.todaysNews})), | |
| catchError(error => of(new LoadNewsError(error))) | |
| ); | |
| }), | |
| ); |