小编Jul*_*n S的帖子

Haskell:显示类型为::* - >*的数据

我有一个问题是为类型的数据类型实现一个show实例

这是代码:

data RMcom = LOAD Int | STORE Int | CLOAD Integer | CADD Integer | 
             CSUB Integer | CMULT Integer | CDIV Integer | ADD Int | 
             SUB Int | MULT Int | DIV Int | GOTO Integer | JZERO Integer | 
             END deriving (Eq, Show, Read)

type RMprog = Integer -> RMcom

type Register = Int -> Integer

data RMstate = State {progr :: RMprog, pc :: Integer, reg :: Register, maxReg :: Int}
Run Code Online (Sandbox Code Playgroud)

它是Registermachine的模拟

所以现在我想自己创建一个Show RMstate的实例. …

haskell types show

2
推荐指数
1
解决办法
142
查看次数

使用DevicePolicyManager锁定屏幕

我知道这不是第一次提出这个问题,但我无法找到解决问题的方法.

这是给你们的一些代码:

MainActivity.class:

package com.fromscratch.aside;


import android.app.admin.DeviceAdminReceiver;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class MainActivity extends ActionBarActivity implements View.OnClickListener {

DevicePolicyManager mDPM;
ComponentName mAdminName;
protected static final int REQUEST_ENABLE = 0;
private Button bLockButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mAdminName = new ComponentName(MainActivity.this,MyAdmin.class);
    mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
    bLockButton = (Button)findViewById(R.id.lock_button);
    bLockButton.setOnClickListener(this);
}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this …
Run Code Online (Sandbox Code Playgroud)

android

1
推荐指数
1
解决办法
2163
查看次数

使用多个参数映射树

我有一个map函数和递归的问题.

我有一个像这样的Tree数据结构:

data Tree a = T a [Tree a] deriving (Eq,Ord,Show)
Run Code Online (Sandbox Code Playgroud)

我已经有了一个工作函数来计算"通过"树的工作原理.

count :: Tree a -> Int
count (T _ xs) = 1 + sum(map count xs)
Run Code Online (Sandbox Code Playgroud)

不,我想要一个函数来用谓词证明树的每个元素

filterKnoten :: (a -> Bool) -> Tree a -> [a]
filterKnoten p (T x []) = (if p(x) then [x] else []) 
filterKnoten p (T x xs) 
                    | p(x) == True = x:(map multP xs)
                    | p(x) == False = map multP xs
                    where multP = filterKnoten p
Run Code Online (Sandbox Code Playgroud)

一些样本日期将是

ex1 …
Run Code Online (Sandbox Code Playgroud)

tree haskell

0
推荐指数
1
解决办法
91
查看次数

标签 统计

haskell ×2

android ×1

show ×1

tree ×1

types ×1