fork download
  1. printl_list([H|X]):-
  2. put_code(H), printl_list(X).
  3.  
  4. read_line_codes(A, L) :-
  5. get_code(C),
  6. ( C == -1
  7. -> ( A == []
  8. -> L = end_of_file
  9. ; reverse(A, L)
  10. )
  11. ; ( C == 0'\n
  12. -> reverse(A, L)
  13. ; read_line_codes([C|A], L)
  14. )
  15. ).
  16.  
  17. :- initialization(main).
  18. main :-
  19. repeat,
  20. read_line_codes([], X),
  21. (X == [52,50]
  22. -> (
  23. halt
  24. )
  25. ; (
  26. nl,
  27. printl_list(X)
  28. )),
  29. X == end_of_file,
  30. halt.
Success #stdin #stdout 0.01s 5292KB
stdin
1// packages/app/src/sandbox/eval/manager.ts

import { SandboxInstance } from './types'; // Assume you have a type for sandbox instances

class SandboxManager {
  private sandboxes: Map<string, SandboxInstance>;

  constructor() {
    this.sandboxes = new Map();
  }

  // Create a new sandbox instance
  createSandbox(id: string, code: string): SandboxInstance {
    const sandbox = this.initializeSandbox(code);
    this.sandboxes.set(id, sandbox);
    return sandbox;
  }

  // Retrieve an existing sandbox
  getSandbox(id: string): SandboxInstance | undefined {
    return this.sandboxes.get(id);
  }

  // Destroy a sandbox instance
  destroySandbox(id: string): boolean {
    if (this.sandboxes.has(id)) {
      const sandbox = this.sandboxes.get(id);
      sandbox?.terminate(); // Assume terminate method exists
      this.sandboxes.delete(id);
      return true;
    }
    return false;
  }

  // Initialize sandbox environment
  private initializeSandbox(code: string): SandboxInstance {
    // Placeholder for sandbox creation logic
    const sandbox: SandboxInstance = {
      id: generateUniqueId(),
      code,
      terminate() {
        // Cleanup logic
      },
    };
    // Optionally, run or evaluate code here
    return sandbox;
  }
}

// Helper function to generate unique IDs
function generateUniqueId(): string {
  return Math.random().toString(36).substr(2, 9);
}

export const sandboxManager = new SandboxManager();
2
10
42
11
stdout
1// packages/app/src/sandbox/eval/manager.ts

import { SandboxInstance } from './types'; // Assume you have a type for sandbox instances

class SandboxManager {
  private sandboxes: Map<string, SandboxInstance>;

  constructor() {
    this.sandboxes = new Map();
  }

  // Create a new sandbox instance
  createSandbox(id: string, code: string): SandboxInstance {
    const sandbox = this.initializeSandbox(code);
    this.sandboxes.set(id, sandbox);
    return sandbox;
  }

  // Retrieve an existing sandbox
  getSandbox(id: string): SandboxInstance | undefined {
    return this.sandboxes.get(id);
  }

  // Destroy a sandbox instance
  destroySandbox(id: string): boolean {
    if (this.sandboxes.has(id)) {
      const sandbox = this.sandboxes.get(id);
      sandbox?.terminate(); // Assume terminate method exists
      this.sandboxes.delete(id);
      return true;
    }
    return false;
  }

  // Initialize sandbox environment
  private initializeSandbox(code: string): SandboxInstance {
    // Placeholder for sandbox creation logic
    const sandbox: SandboxInstance = {
      id: generateUniqueId(),
      code,
      terminate() {
        // Cleanup logic
      },
    };
    // Optionally, run or evaluate code here
    return sandbox;
  }
}

// Helper function to generate unique IDs
function generateUniqueId(): string {
  return Math.random().toString(36).substr(2, 9);
}

export const sandboxManager = new SandboxManager();
2
10